Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local gls = component.glasses
- gls.removeAll()
- local hintText = gls.addText2D()
- hintText.setText("Activate the overlay to see the toy GUI")
- hintText.addAutoTranslation(50, 80)
- hintText.setHorizontalAlign("center")
- hintText.setCondition(hintText.addScale(0, 0, 0), "OVERLAY_ACTIVE", true)
- local addBlockButton = gls.addBox2D()
- local addBlockLabel = gls.addText2D()
- addBlockLabel.setCondition(addBlockLabel.addScale(0, 0, 0), "OVERLAY_INACTIVE", true)
- addBlockButton.setCondition(addBlockButton.addScale(0,0,0), "OVERLAY_INACTIVE", true)
- addBlockLabel.setText("Add Block")
- addBlockLabel.addTranslation(50, 10, 0)
- addBlockLabel.setHorizontalAlign("center")
- addBlockLabel.setVerticalAlign("middle")
- addBlockButton.setSize(100, 20, 0)
- addBlockButton.addColor(0, 0, 0, 0.95)
- addBlockButton.addColor(0, 0, 0, 0.95)
- local state = "normal"
- local function evt_overlay_click(evt, comp, user, x, y, btn)
- if state == "normal" then
- if x > 0 and y > 0 and x < 100 and y < 20 and btn == 0 then
- print("Placing virtual block...")
- state = "place-virtual-block"
- end
- end
- end
- local function evt_world_interact(evt, comp, user, px, py, pz, plx, ply, plz, rot, bx, by, bz, side)
- if state == "place-virtual-sign" then
- local sign = gls.addText3D()
- sign.setText("Position: " .. bx .. "," .. by .. "," .. bz)
- sign.addTranslate(bx, by, bz)
- sign.addScale(0.1, 0.1, 0.1)
- print("Placed virtual sign.")
- state = "normal"
- elseif state == "place-virtual-block" then
- local blck = gls.addCube3D()
- blck.addTranslate(bx, by + 1, bz)
- print("Placed virtual block")
- state = "normal"
- end
- end
- event.listen("interact_overlay", evt_overlay_click)
- event.listen("interact_world_block_left", evt_world_interact)
- event.pull("interrupted")
- event.ignore("interact_overlay", evt_overlay_click)
- event.ignore("interact_world_block_left", evt_world_interact)
- gls.removeAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement