# Builds Fishing.rbxlx (place file for Roblox Studio) and install/* from src/. # Run: powershell -ExecutionPolicy Bypass -File build.ps1 # Fishing.rbxlx is created only if it does not exist yet: after the map is baked in Studio # (WorldBuilder) the place file holds the hand-edited map, and scripts reach it via Rojo. # Use -Force to recreate it from scratch (this DELETES the map built in Studio). param([switch]$Force) $root = $PSScriptRoot $enc = New-Object System.Text.UTF8Encoding($false) $scripts = @( @{ Name = 'FishConfig'; Class = 'ModuleScript'; Service = 'ReplicatedStorage'; Path = 'src\ReplicatedStorage\FishConfig.lua'; Rbxmx = '1_FishConfig_ReplicatedStorage.rbxmx' }, @{ Name = 'GameModels'; Class = 'ModuleScript'; Service = 'ReplicatedStorage'; Path = 'src\ReplicatedStorage\GameModels.lua'; Rbxmx = '2_GameModels_ReplicatedStorage.rbxmx' }, @{ Name = 'MapBuilder'; Class = 'Script'; Service = 'ServerScriptService'; Path = 'src\ServerScriptService\MapBuilder.server.lua'; Rbxmx = '3_MapBuilder_ServerScriptService.rbxmx' }, @{ Name = 'GameServer'; Class = 'Script'; Service = 'ServerScriptService'; Path = 'src\ServerScriptService\GameServer.server.lua'; Rbxmx = '4_GameServer_ServerScriptService.rbxmx' }, @{ Name = 'World1Builder'; Class = 'ModuleScript'; Service = 'ServerScriptService'; Path = 'src\ServerScriptService\World1Builder.lua'; Rbxmx = '6_World1Builder_ServerScriptService.rbxmx' }, @{ Name = 'WorldBuilder'; Class = 'ModuleScript'; Service = 'ServerScriptService'; Path = 'src\ServerScriptService\WorldBuilder.lua'; Rbxmx = '7_WorldBuilder_ServerScriptService.rbxmx' }, @{ Name = 'FishingClient'; Class = 'LocalScript'; Service = 'StarterPlayerScripts'; Path = 'src\StarterPlayer\StarterPlayerScripts\FishingClient.client.lua'; Rbxmx = '5_FishingClient_StarterPlayerScripts.rbxmx' }, @{ Name = 'Loading'; Class = 'LocalScript'; Service = 'ReplicatedFirst'; Path = 'src\ReplicatedFirst\Loading.client.lua'; Rbxmx = '8_Loading_ReplicatedFirst.rbxmx' } ) $header = '' $script:ref = 0 function NextRef { $script:ref++; return "RBX$($script:ref)" } function ScriptItem($s) { $src = [System.IO.File]::ReadAllText((Join-Path $root $s.Path), $enc) if ($src.Contains(']]>')) { throw "CDATA conflict in $($s.Path)" } return "$($s.Name)`n" } function ServiceItem($class, $children) { return "$class`n$children`n" } # --- place file --- $rs = ($scripts | Where-Object { $_.Service -eq 'ReplicatedStorage' } | ForEach-Object { ScriptItem $_ }) -join '' $sss = ($scripts | Where-Object { $_.Service -eq 'ServerScriptService' } | ForEach-Object { ScriptItem $_ }) -join '' $sps = ($scripts | Where-Object { $_.Service -eq 'StarterPlayerScripts' } | ForEach-Object { ScriptItem $_ }) -join '' $rf = ($scripts | Where-Object { $_.Service -eq 'ReplicatedFirst' } | ForEach-Object { ScriptItem $_ }) -join '' $place = $header + "`n" + (ServiceItem 'ReplicatedFirst' $rf) + (ServiceItem 'ReplicatedStorage' $rs) + (ServiceItem 'ServerScriptService' $sss) + (ServiceItem 'StarterPlayer' (ServiceItem 'StarterPlayerScripts' $sps)) + "`n" $placePath = Join-Path $root 'Fishing.rbxlx' if ($Force -or -not (Test-Path $placePath)) { [System.IO.File]::WriteAllText($placePath, $place, $enc) Write-Host "Built Fishing.rbxlx" } else { Write-Host "Fishing.rbxlx already exists - left untouched (it holds the map built in Studio; scripts come via Rojo). Use -Force to recreate." } # --- install/*.rbxmx and install/INSTALL.lua --- $installDir = Join-Path $root 'install' New-Item -ItemType Directory -Force $installDir | Out-Null $parents = @{ ReplicatedStorage = 'game.ReplicatedStorage'; ServerScriptService = 'game.ServerScriptService'; StarterPlayerScripts = 'game.StarterPlayer.StarterPlayerScripts'; ReplicatedFirst = 'game.ReplicatedFirst' } $sb = New-Object System.Text.StringBuilder [void]$sb.Append("local function make(class, name, parent, src)`n local old = parent:FindFirstChild(name)`n if old then old:Destroy() end`n local s = Instance.new(class)`n s.Name = name`n s.Source = src`n s.Parent = parent`nend`nlocal oldMap = workspace:FindFirstChild('FishingMap')`nif oldMap then oldMap:Destroy() end`n") foreach ($s in $scripts) { $src = [System.IO.File]::ReadAllText((Join-Path $root $s.Path), $enc) if ($src.Contains(']=====]')) { throw "Long-string conflict in $($s.Path)" } [void]$sb.Append("make('$($s.Class)', '$($s.Name)', $($parents[$s.Service]), [=====[" + $src + "]=====])`n") $script:ref = 0 $xml = $header + "`n" + (ScriptItem $s) + "`n" [System.IO.File]::WriteAllText((Join-Path $installDir $s.Rbxmx), $xml, $enc) } [void]$sb.Append("print('DONE! $($scripts.Count) scripts installed. Press Play (F5).')`n") [System.IO.File]::WriteAllText((Join-Path $installDir 'INSTALL.lua'), $sb.ToString(), $enc) Write-Host "Built install/"