forked from pilsprog/skyport-lovegraphics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collectInfo.lua
53 lines (47 loc) · 1.05 KB
/
collectInfo.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
collectInfo = {}
ipCounter = 1
ipInfo = {"",""}
function collectInfo.update(dt)
if(init) then
waitingForInfo = true
init = false
end
if waitingForInfo == false then
exit = true
end
if exit then
ip = ipInfo[1]
port = tonumber(ipInfo[2])
init = true
exit = false
mode = 2
end
end
function collectInfo.draw()
local marker = {"",""}
if ipCounter == 1 then
marker[1] = "|"
else
marker[2] = "|"
end
love.graphics.print("IP: " .. ipInfo[1] .. marker[1], 300, 200)
love.graphics.print("Port: " .. ipInfo[2] .. marker[2], 300, 230)
end
function collectInfo.keypressed(key, unicode)
if unicode > 45 and unicode < 58 and unicode ~= 47 then
ipInfo[ipCounter] = ipInfo[ipCounter] .. key
end
if key == "return" or key == "tab" or key == "down" then
if ipCounter == 2 then waitingForInfo = false
else
ipCounter = 2
if ipInfo[1] == "" then
ipInfo[1] = "127.0.0.1"
end
end
end
if key == "up" and ipCounter == 2 then ipCounter = 1 end
if key == "backspace" then
ipInfo[ipCounter] = string.sub(ipInfo[ipCounter], 1, -2)
end
end