Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nsp = require("nsp_core")
- local turtle_location = nsp_core.unserialize("turtle_location")
- if turtle_location == nil then
- turtle_location = {["x"] = 0,["z"] = 0,["y"] = 0,["f"] = "N",["name"] = os.getComputerLabel()}
- end
- turtle_location["name"] = os.getComputerLabel()
- local args = { ... }
- if #args == 3 or #args == 4 then
- local arguemnt_1_number = tonumber(args[1])
- if type(arguemnt_1_number) == "number" then
- turtle_location["x"] = arguemnt_1_number
- end
- local arguemnt_2_number = tonumber(args[3])
- if type(arguemnt_2_number) == "number" then
- turtle_location["y"] = arguemnt_2_number
- end
- local arguemnt_3_number = tonumber(args[2])
- if type(arguemnt_3_number) == "number" then
- turtle_location["z"] = arguemnt_3_number
- end
- if #args == 4 then
- local argument_4 = args[4]
- if argument_4 == "N" or "E" or "S" or "W" then
- turtle_location["f"] = argument_4
- end
- end
- nsp_core.serialize(turtle_location, "turtle_location")
- return
- else
- --IS X
- print ("Where an I on the following Axis? if I am right just click enter if not, correct me with a number only")
- print ("---")
- print ("X Axis: " .. turtle_location["x"])
- local x_answer = io.read()
- if x_answer == "" then
- print ("Ah so I was right, good. I am at X: ".. turtle_location["x"])
- else
- local x_answer_num = tonumber(x_answer)
- if x_answer_num == nil then
- print ("I don't understand that, I will just leave it as it was")
- else
- print ("I am at, ".. x_answer_num .. ", I will remember that.")
- turtle_location["x"] = x_answer_num
- end
- end
- --IS Z -
- print ("---")
- print ("Z Axis: " .. turtle_location["z"])
- local z_answer = io.read()
- if z_answer == "" then
- print ("Ah so I was right, good. I am at Z: ".. turtle_location["z"])
- else
- local answer_num = tonumber(z_answer)
- if answer_num == nil then
- print ("I don't understand that, I will just leave it as it was")
- else
- print ("I am at, ".. answer_num .. ", I will remember that.")
- turtle_location["z"] = answer_num
- end
- end
- --Is Y, Height-
- print ("---")
- print ("Y Axis: " .. turtle_location["y"])
- local y_answer = io.read()
- if y_answer == "" then
- print ("Ah so I was right, good. I am at Y: ".. turtle_location["y"])
- else
- local answer_num = tonumber(y_answer)
- if answer_num == nil then
- print ("I don't understand that, I will just leave it as it was")
- else
- print ("I am at, ".. answer_num .. ".")
- turtle_location["y"] = answer_num
- end
- end
- --Am facing? --
- print ("---")
- print ("Which way am I faceing, wright N E S W")
- local y_answer = io.read()
- if argument_4 == "N" or
- argument_4 == "E" or
- argument_4 == "S" or
- argument_4 == "W" then
- print("Facing: " .. argument_4)
- turtle_location["f"] = argument_4
- end
- --save it--
- nsp_core.serialize(turtle_location, "turtle_location")
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement