mirror of
https://github.com/LDDestroier/CC/
synced 2025-07-07 04:22:55 +00:00
Fixed P2 skynet ping indicator / assist
This commit is contained in:
parent
fed06ed6e2
commit
fc38840221
46
tron.lua
46
tron.lua
@ -19,6 +19,7 @@ local doDrawPlayerNames = true -- draws the names of players onscreen
|
|||||||
local doRenderOwnName = false -- if doDrawPlayerNames, also draws your own name
|
local doRenderOwnName = false -- if doDrawPlayerNames, also draws your own name
|
||||||
local useSetVisible = false -- use term.current().setVisible, which speeds things up at the cost of multishell
|
local useSetVisible = false -- use term.current().setVisible, which speeds things up at the cost of multishell
|
||||||
local gridID = 1 -- determines which grid is used
|
local gridID = 1 -- determines which grid is used
|
||||||
|
local mode = "menu"
|
||||||
|
|
||||||
-- initial grid information, (hopefully) transferred to non-host players
|
-- initial grid information, (hopefully) transferred to non-host players
|
||||||
local initGrid = {
|
local initGrid = {
|
||||||
@ -436,6 +437,8 @@ 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)
|
||||||
|
term.clear()
|
||||||
|
cwrite("Connecting to Skynet...", scr_y / 2)
|
||||||
skynet.open(port)
|
skynet.open(port)
|
||||||
else
|
else
|
||||||
term.clear()
|
term.clear()
|
||||||
@ -446,6 +449,7 @@ if not doGridDemo then
|
|||||||
file.write(prog.readAll())
|
file.write(prog.readAll())
|
||||||
file.close()
|
file.close()
|
||||||
skynet = dofile(skynetPath)
|
skynet = dofile(skynetPath)
|
||||||
|
cwrite("Connecting to Skynet...", 1 + scr_y / 2)
|
||||||
skynet.open(port)
|
skynet.open(port)
|
||||||
else
|
else
|
||||||
error("Could not download Skynet.")
|
error("Could not download Skynet.")
|
||||||
@ -1264,7 +1268,7 @@ local parseMouseInput = function(button, x, y, direction)
|
|||||||
local cx = x - scr_mx
|
local cx = x - scr_mx
|
||||||
local cy = y - scr_my
|
local cy = y - scr_my
|
||||||
|
|
||||||
if useLegacyMouseControl then -- outdated mouse input
|
if useLegacyMouseControl or mode == "demo" then -- outdated mouse input, useful for grid demo though
|
||||||
cx = cx * (scr_y / scr_x)
|
cx = cx * (scr_y / scr_x)
|
||||||
if cx > cy then
|
if cx > cy then
|
||||||
if -cx > cy then
|
if -cx > cy then
|
||||||
@ -1380,13 +1384,13 @@ local gridDemo = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sendInfo = function(gameID)
|
local sendInfo = function(gameID, doSendTime)
|
||||||
transmit(port, {
|
transmit(port, {
|
||||||
player = isHost and player or nil,
|
player = isHost and player or nil,
|
||||||
name = player[you].name,
|
name = player[you].name,
|
||||||
putTrail = isPuttingDown,
|
putTrail = isPuttingDown,
|
||||||
gameID = gameID,
|
gameID = gameID,
|
||||||
time = os.epoch("utc"),
|
time = doSendTime and os.epoch("utc"),
|
||||||
keysDown = isHost and nil or keysDown,
|
keysDown = isHost and nil or keysDown,
|
||||||
trail = isHost and lastTrails or nil,
|
trail = isHost and lastTrails or nil,
|
||||||
deadGuys = isHost and deadGuys or nil,
|
deadGuys = isHost and deadGuys or nil,
|
||||||
@ -1417,7 +1421,7 @@ local deadAnimation = function(doSend)
|
|||||||
lockInput = true
|
lockInput = true
|
||||||
end
|
end
|
||||||
if doSend then
|
if doSend then
|
||||||
sendInfo(gamename)
|
sendInfo(gamename, isHost)
|
||||||
end
|
end
|
||||||
if deadGuys[you] or deadGuys[nou] then
|
if deadGuys[you] or deadGuys[nou] then
|
||||||
termsetTextColor(colors.white)
|
termsetTextColor(colors.white)
|
||||||
@ -1538,7 +1542,7 @@ local game = function()
|
|||||||
else
|
else
|
||||||
setDirection(p, nil, control[lastDirectionPressed])
|
setDirection(p, nil, control[lastDirectionPressed])
|
||||||
isPuttingDown = not keysDown[control.release]
|
isPuttingDown = not keysDown[control.release]
|
||||||
sendInfo(gamename)
|
sendInfo(gamename, isHost)
|
||||||
end
|
end
|
||||||
|
|
||||||
if miceDown[3] then
|
if miceDown[3] then
|
||||||
@ -1712,20 +1716,26 @@ end
|
|||||||
local decision
|
local decision
|
||||||
|
|
||||||
local main = function()
|
local main = function()
|
||||||
local rVal
|
return pcall(function()
|
||||||
while true do
|
local rVal
|
||||||
decision = titleScreen()
|
while true do
|
||||||
lockInput = false
|
mode = "menu"
|
||||||
if decision == "start" then
|
decision = titleScreen()
|
||||||
startGame()
|
lockInput = false
|
||||||
elseif decision == "help" then
|
if decision == "start" then
|
||||||
helpScreen()
|
mode = "game"
|
||||||
elseif decision == "demo" then
|
startGame()
|
||||||
parallel.waitForAny( getInput, gridDemo )
|
elseif decision == "help" then
|
||||||
elseif decision == "exit" then
|
mode = "help"
|
||||||
return cleanExit()
|
helpScreen()
|
||||||
|
elseif decision == "demo" then
|
||||||
|
mode = "demo"
|
||||||
|
parallel.waitForAny( getInput, gridDemo )
|
||||||
|
elseif decision == "exit" then
|
||||||
|
return cleanExit()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if doGridDemo then
|
if doGridDemo then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user