mirror of
https://github.com/LDDestroier/CC/
synced 2025-06-26 15:12:52 +00:00
Added toggle for Skynet in options
The path for skynet is also changed. It will now only download to the same directory as the main game program is in.
This commit is contained in:
parent
cc93596367
commit
396130487d
53
tron.lua
53
tron.lua
@ -352,7 +352,7 @@ if useSkynet and (not http.websocket) then
|
|||||||
error("Skynet is not supported on this version of ComputerCraft.")
|
error("Skynet is not supported on this version of ComputerCraft.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local skynetPath = fs.combine(fs.getDir(shell.getRunningProgram()), "skynet")
|
local skynetPath = fs.combine(fs.getDir(shell.getRunningProgram()), "skynet.lua")
|
||||||
local skynetURL = "https://raw.githubusercontent.com/osmarks/skynet/master/client.lua"
|
local skynetURL = "https://raw.githubusercontent.com/osmarks/skynet/master/client.lua"
|
||||||
|
|
||||||
if argumentName then
|
if argumentName then
|
||||||
@ -463,13 +463,14 @@ end
|
|||||||
|
|
||||||
local cwrite = function(text, y, xdiff, wordPosCheck)
|
local cwrite = function(text, y, xdiff, wordPosCheck)
|
||||||
wordPosCheck = wordPosCheck or #text
|
wordPosCheck = wordPosCheck or #text
|
||||||
termsetCursorPos(mathfloor(scr_x / 2 - (#text + (xdiff or 0)) / 2), y or (scr_y - 2))
|
termsetCursorPos(mathfloor(scr_x / 2 - math.floor(0.5 + #text + (xdiff or 0)) / 2), y or (scr_y - 2))
|
||||||
term.write(text)
|
term.write(text)
|
||||||
return (scr_x / 2) - (#text / 2) + wordPosCheck
|
return (scr_x / 2) - (#text / 2) + wordPosCheck
|
||||||
end
|
end
|
||||||
|
|
||||||
local modem, skynet
|
local modem, skynet
|
||||||
if not doGridDemo then
|
local setUpModem = function()
|
||||||
|
if not doGridDemo then
|
||||||
if useSkynet then
|
if useSkynet then
|
||||||
if fs.exists(skynetPath) then
|
if fs.exists(skynetPath) then
|
||||||
skynet = dofile(skynetPath)
|
skynet = dofile(skynetPath)
|
||||||
@ -503,7 +504,9 @@ if not doGridDemo then
|
|||||||
error("You should attach a modem.")
|
error("You should attach a modem.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
setUpModem()
|
||||||
|
|
||||||
local transmit = function(port, message)
|
local transmit = function(port, message)
|
||||||
if useSkynet then
|
if useSkynet then
|
||||||
@ -1258,12 +1261,6 @@ local titleScreen = function()
|
|||||||
"Exit"
|
"Exit"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
options = {
|
|
||||||
"Grid Demo",
|
|
||||||
"Change Name",
|
|
||||||
"Change Grid",
|
|
||||||
"Back..."
|
|
||||||
}
|
|
||||||
while true do
|
while true do
|
||||||
choice, scrollInfo = makeMenu(2, scr_y - #menuOptions, menuOptions, true, scrollInfo)
|
choice, scrollInfo = makeMenu(2, scr_y - #menuOptions, menuOptions, true, scrollInfo)
|
||||||
if choice == 1 then
|
if choice == 1 then
|
||||||
@ -1273,7 +1270,14 @@ local titleScreen = function()
|
|||||||
elseif choice == 3 then
|
elseif choice == 3 then
|
||||||
local _cpos
|
local _cpos
|
||||||
while true do
|
while true do
|
||||||
choice, scrollInfo = makeMenu(14, scr_y - #menuOptions, options, true, scrollInfo, _cpos)
|
options = {
|
||||||
|
"Grid Demo",
|
||||||
|
"Change Name",
|
||||||
|
"Change Grid",
|
||||||
|
(useSkynet and "Disable" or "Enable") .. " Skynet",
|
||||||
|
"Back..."
|
||||||
|
}
|
||||||
|
choice, scrollInfo = makeMenu(14, scr_y - #options, options, true, scrollInfo, _cpos)
|
||||||
_cpos = choice
|
_cpos = choice
|
||||||
if choice == 1 then
|
if choice == 1 then
|
||||||
return "demo"
|
return "demo"
|
||||||
@ -1292,6 +1296,25 @@ local titleScreen = function()
|
|||||||
gridID = (gridID % #gridList) + 1
|
gridID = (gridID % #gridList) + 1
|
||||||
gridFore, gridBack = table.unpack(gridList[gridID])
|
gridFore, gridBack = table.unpack(gridList[gridID])
|
||||||
elseif choice == 4 then
|
elseif choice == 4 then
|
||||||
|
if http.websocket then
|
||||||
|
useSkynet = not useSkynet
|
||||||
|
setUpModem()
|
||||||
|
if skynet and not useSkynet then
|
||||||
|
skynet.socket.close()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
term.clear()
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
cwrite("Alas, this version of CC", -2 + scr_y / 2)
|
||||||
|
cwrite("does not support Skynet.", -1 + scr_y / 2)
|
||||||
|
term.setTextColor(colors.lightGray)
|
||||||
|
cwrite("Use CC:Tweaked or CCEmuX", 1 + scr_y / 2)
|
||||||
|
cwrite("instead for netplay.", 2 + scr_y / 2)
|
||||||
|
cwrite("Press any key to go back.", 4 + scr_y / 2)
|
||||||
|
sleep(0.1)
|
||||||
|
os.pullEvent("key")
|
||||||
|
end
|
||||||
|
elseif choice == 5 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1795,7 +1818,11 @@ local main = function()
|
|||||||
lockInput = false
|
lockInput = false
|
||||||
if decision == "start" then
|
if decision == "start" then
|
||||||
mode = "game"
|
mode = "game"
|
||||||
|
if useSkynet then
|
||||||
|
parallel.waitForAny(startGame, skynet.listen)
|
||||||
|
else
|
||||||
startGame()
|
startGame()
|
||||||
|
end
|
||||||
elseif decision == "help" then
|
elseif decision == "help" then
|
||||||
mode = "help"
|
mode = "help"
|
||||||
helpScreen()
|
helpScreen()
|
||||||
@ -1840,12 +1867,10 @@ else
|
|||||||
startGame()
|
startGame()
|
||||||
end
|
end
|
||||||
term.setCursorPos(1, scr_y)
|
term.setCursorPos(1, scr_y)
|
||||||
else
|
|
||||||
if useSkynet then
|
|
||||||
parallel.waitForAny(main, skynet.listen)
|
|
||||||
skynet.socket.close()
|
|
||||||
else
|
else
|
||||||
main()
|
main()
|
||||||
|
if skynet then
|
||||||
|
skynet.socket.close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user