Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modules = peripheral.find("neuralInterface")
- rednet.open("top")
- local buttons = {
- {
- name = "RocketJump",
- pos = {40, 16},
- size = {50, 10},
- func = function()
- for i=1,4 do
- modules.launch(0,5,0)
- end
- end
- }
- }
- --[=[
- local function InitButtons()
- for i,v in ipairs(buttons) do
- local group = canvas.addGroup(v.pos)
- group.addRectangle(0,0, v.size[1], v.size[2], 0xFF000064)
- local text = group.addText({ 5, 5 }, v.name or v.text)
- end
- end
- --init stuffs
- InitButtons()
- ]=]
- local previousLocationBroadcast = 0
- local eventFunctions = {
- --[[
- glasses_click = function(event,button,x,y)
- for i,v in ipairs(buttons) do
- --collision check
- if x >= v.pos[1] and x < v.pos[1] + v.size[1] and y >= v.pos[2] and y < v.pos[2] + v.size[2] then
- --fire func if true
- v.func()
- end
- end
- print( "The mouse button ", button, " was pressed at ", x, " and ", y )
- end,
- ]]
- key = function(event,key,isHeld,arg4)
- playerMeta = modules.getMetaOwner()
- if not playerMeta then return end
- if key == keys.space then
- --for i=1,2 do
- modules.launch(playerMeta.yaw, playerMeta.pitch, 1)
- --modules.launch(0,5,0)
- --end
- end
- end,
- customTick = function()
- playerMeta = modules.getMetaOwner()
- if not playerMeta then return end
- if os.clock() - previousLocationBroadcast > 0.1 then
- previousLocationBroadcast = os.clock()
- local x,y,z = gps.locate()
- if x and y and z then
- local playerPosTable = {
- x,
- y,
- z,
- playerMeta.yaw,
- playerMeta.pitch
- }
- --print(textutils.serialize(playerPosTable))
- rednet.broadcast(textutils.serialize(playerPosTable), "u2")
- else
- --error("Error! Could not get smartGlasses.gps.locate()")
- end
- end
- end
- }
- local str = ""
- for i,v in pairs(modules.getMetaOwner()) do
- str = str..i.." : "
- end
- print(str)
- os.queueEvent("abc")
- --main loop
- while true do
- local event, arg2, arg3, arg4 = os.pullEvent()
- local eventFunc = eventFunctions[event]
- if eventFunc then
- eventFunc(event, arg2, arg3, arg4)
- end
- eventFunctions.customTick()
- if event == "timer" then
- os.startTimer(0.08)
- end
- end
Add Comment
Please, Sign In to add comment