Add more
This commit is contained in:
parent
89a15d277f
commit
f7bb6c8137
5 changed files with 1055 additions and 0 deletions
68
client.lua
Normal file
68
client.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
local modules = {}
|
||||
|
||||
local function getIndex(tab, val)
|
||||
local index = nil
|
||||
for i, v in ipairs (tab) do
|
||||
if (v == val) then
|
||||
index = i
|
||||
end
|
||||
end
|
||||
return index
|
||||
end
|
||||
|
||||
|
||||
local kinetic = peripheral.wrap("back")
|
||||
local canvas = peripheral.wrap("back").canvas()
|
||||
|
||||
timer = os.startTimer(0.5)
|
||||
canvas.clear()
|
||||
|
||||
local group = canvas.addGroup({ 0, 0 })
|
||||
local text = group.addText({ 5, 5 }, "")
|
||||
|
||||
text.setText("this is NOT a client")
|
||||
|
||||
local moduleText = group.addText({ 5, 15 }, table.concat(modules, "\n"))
|
||||
moduleText.setScale(0.5)
|
||||
local function enableModule(module)
|
||||
table.insert(modules, module)
|
||||
moduleText.setText(table.concat(modules, "\n"))
|
||||
end
|
||||
|
||||
local function disableModule(module)
|
||||
local idx = getIndex(modules, module)
|
||||
table.remove(modules, idx)
|
||||
moduleText.setText(table.concat(modules, "\n"))
|
||||
end
|
||||
|
||||
local function isModuleEnabled(module)
|
||||
local idx = getIndex(modules, module)
|
||||
return idx ~= nil
|
||||
end
|
||||
|
||||
function checkKey()
|
||||
while true do
|
||||
local event, key, is_held = os.pullEvent("key")
|
||||
if keys.getName(key) == "g" then
|
||||
if isModuleEnabled("flight") then
|
||||
disableModule("flight")
|
||||
else
|
||||
enableModule("flight")
|
||||
timer = os.startTimer(0.5)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function flyEvent()
|
||||
while true do
|
||||
local _, tid = os.pullEvent("timer")
|
||||
if tid == timer and isModuleEnabled("flight") then
|
||||
timer = os.startTimer(0.5)
|
||||
kinetic.launch(0, -90, 4);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parallel.waitForAll(checkKey, flyEvent)
|
||||
Loading…
Add table
Add a link
Reference in a new issue