Fishing RBLXL
This commit is contained in:
1 parent
83cd5355b8
commit
f316a9bf0c
8 files changed
+81
-43
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# Builds Fishing.rbxlx (place file for Roblox Studio) and install/* from src/.
|
||||
# Run: powershell -ExecutionPolicy Bypass -File build.ps1
|
||||
|
||||
$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 = 'FishingClient'; Class = 'LocalScript'; Service = 'StarterPlayerScripts'; Path = 'src\StarterPlayer\StarterPlayerScripts\FishingClient.client.lua'; Rbxmx = '5_FishingClient_StarterPlayerScripts.rbxmx' }
|
||||
)
|
||||
|
||||
$header = '<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">'
|
||||
$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 "<Item class=`"$($s.Class)`" referent=`"$(NextRef)`"><Properties><string name=`"Name`">$($s.Name)</string><ProtectedString name=`"Source`"><![CDATA[$src]]></ProtectedString></Properties></Item>`n"
|
||||
}
|
||||
|
||||
function ServiceItem($class, $children) {
|
||||
return "<Item class=`"$class`" referent=`"$(NextRef)`"><Properties><string name=`"Name`">$class</string></Properties>`n$children</Item>`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 ''
|
||||
|
||||
$place = $header + "`n" +
|
||||
(ServiceItem 'ReplicatedStorage' $rs) +
|
||||
(ServiceItem 'ServerScriptService' $sss) +
|
||||
(ServiceItem 'StarterPlayer' (ServiceItem 'StarterPlayerScripts' $sps)) +
|
||||
"</roblox>`n"
|
||||
[System.IO.File]::WriteAllText((Join-Path $root 'Fishing.rbxlx'), $place, $enc)
|
||||
|
||||
# --- 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' }
|
||||
$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) + "</roblox>`n"
|
||||
[System.IO.File]::WriteAllText((Join-Path $installDir $s.Rbxmx), $xml, $enc)
|
||||
}
|
||||
[void]$sb.Append("print('DONE! 5 scripts installed. Press Play (F5).')`n")
|
||||
[System.IO.File]::WriteAllText((Join-Path $installDir 'INSTALL.lua'), $sb.ToString(), $enc)
|
||||
|
||||
Write-Host "Built Fishing.rbxlx and install/"
|
||||
Reference in new issue
Block a user