Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mttp = require("mttp")
- local modem = peripheral.wrap("back")
- local lastInput = ""
- local selectedSlot = turtle.getSelectedSlot()
- local selectedSlotData = {}
- local function printUsage()
- print("Controls:")
- print("Move:", "w", "a", "s", "d")
- print("Up/Down:", "space, ctrl")
- print("Dig(F/U/D):", "f", "r", "v")
- print("Place(F/U/D):", "g", "t", "b")
- print("Attack(Front):", "q")
- end
- local function renderUI()
- term.clear()
- term.setCursorPos(1,1)
- print("last input:", lastInput)
- print("selected", selectedSlot)
- print(" ", selectedSlotData["count"] or 0, selectedSlotData["name"] or "-")
- print("---")
- printUsage()
- end
- while true do
- local event, key, is_held = os.pullEvent("key")
- lastInput = keys.getName(key)
- renderUI()
- if keys["w"] == key then
- mttp.get(modem, "/forward")
- end
- if keys["a"] == key then
- mttp.get(modem, "/turn/left")
- end
- if keys["s"] == key then
- mttp.get(modem, "/back")
- end
- if keys["d"] == key then
- mttp.get(modem, "/turn/right")
- end
- if keys["space"] == key then
- mttp.get(modem, "/up")
- end
- if keys["leftCtrl"] == key then
- mttp.get(modem, "/down")
- end
- if keys["f"] == key then
- mttp.get(modem, "/dig")
- end
- if keys["r"] == key then
- mttp.get(modem, "/dig/up")
- end
- if keys["v"] == key then
- mttp.get(modem, "/dig/down")
- end
- if keys["up"] == key then
- local status, response = mttp.get(modem, "/inv/up")
- if status == 200 then
- selectedSlot = response["slot"]
- selectedSlotData = response["data"]
- end
- end
- if keys["down"] == key then
- mttp.get(modem, "/inv/down")
- end
- if keys["i"] == key then
- local status, response = mttp.get(modem, "/inv")
- term.clear()
- term.setCursorPos(1,1)
- for i = 1, 16, 1 do
- print(("%2s"):format(i), ("%2s"):format(response[i]["count"] or 0), response[i]["name"] or "-")
- end
- end
- renderUI()
- end
Advertisement
Add Comment
Please, Sign In to add comment