Posted 11 August 2017 - 06:21 AM
I'm working on a program to dial other stargates with mouse events. The problem is now that it won't update the screen until you click somewhere. Please help me?
Here is my code:
Thank you in advance!
Here is my code:
sg = peripheral.find("stargate")
laddress = sg.localAddress()
term.clear()
term.setTextColor(colors.lime)
term.setCursorPos(1,1)
o1 = {"Dawson's", "ELO3-VCC-D5"}
o2 = {"Outlying", "ALFO-VR0-SZ"}
o3 = {"Logan", "PGG2-2JL-53"}
o4 = {"Moon", "MLL0-1LI-LP"}
o5 = {"Mars", "ALDQ-TN0-7A"}
o6 = {"Spawn", "BFWG-F9G-8Q"}
print("Local Stargate: "..laddress.." ")
while true do
local event, button, x, y = os.pullEvent("mouse_click")
local sstate = sg.stargateState()
local istate = sg.irisState()
local raddress = sg.remoteAddress()
term.setCursorPos(1,2)
print("Connected Stargate: "..raddress.." ")
term.setCursorPos(1,3)
print("Stargate State: "..sstate.." ")
term.setCursorPos(1,4)
print("Iris State: "..istate.." ")
term.setCursorPos(1,6)
print(o1[1]..": "..o1[2])
term.setCursorPos(1,7)
print(o2[1]..": "..o2[2])
term.setCursorPos(1,8)
print(o3[1]..": "..o3[2])
term.setCursorPos(1,9)
print(o4[1]..": "..o4[2])
term.setCursorPos(1,10)
print(o5[1]..": "..o5[2])
term.setCursorPos(1,11)
print(o6[1]..": "..o6[2])
term.setCursorPos(1,13)
if istate == "Closed" then
print("Open Iris ")
else
print("Close Iris")
end
term.setCursorPos(1,14)
print("Disconnect Stargate")
if y == 6 then
sg.dial(o1[2])
elseif y == 7 then
sg.dial(o2[2])
elseif y == 8 then
sg.dial(o3[2])
elseif y == 9 then
sg.dial(o4[2])
elseif y == 10 then
sg.dial(o5[2])
elseif y == 11 then
sg.dial(o6[2])
elseif y == 13 then
if istate == "Closed" then
sg.openIris()
else
sg.closeIris()
end
elseif y == 14 then
sg.disconnect()
end
sleep(0.1)
end
Thank you in advance!