# set_current.lua

Jun 26th, 2022
596
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. nsp = require("nsp_core")
2.
3. local turtle_location = nsp_core.unserialize("turtle_location")
4. if turtle_location == nil then
5.     turtle_location = {["x"] = 0,["z"] = 0,["y"] = 0,["f"] = "N",["name"] = os.getComputerLabel()}
6. end
7. turtle_location["name"] = os.getComputerLabel()
8.
9. local args = { ... }
10. if #args == 3 or #args ==  4 then
11.     local arguemnt_1_number = tonumber(args[1])
12.     if type(arguemnt_1_number) == "number" then
13.     turtle_location["x"] = arguemnt_1_number
14.     end
15.     local arguemnt_2_number = tonumber(args[3])
16.     if type(arguemnt_2_number) == "number" then
17.     turtle_location["y"] = arguemnt_2_number
18.     end
19.     local arguemnt_3_number = tonumber(args[2])
20.     if type(arguemnt_3_number) == "number" then
21.     turtle_location["z"] = arguemnt_3_number
22.     end
23.     if #args == 4 then
24.         local argument_4 = args[4]
25.         if argument_4 == "N" or "E" or "S" or "W" then
26.             turtle_location["f"] = argument_4
27.         end
28.     end
29.     nsp_core.serialize(turtle_location, "turtle_location")
30.     return
31. else
32.     --IS X
33.     print ("Where an I on the following Axis? if I am right just click enter if not, correct me with a number only")
34.     print ("---")
35.     print ("X Axis: " .. turtle_location["x"])
36.
38.
39.     if x_answer == "" then
40.        print ("Ah so I was right, good. I am at X: ".. turtle_location["x"])
41.     else
43.         if x_answer_num == nil then
44.             print ("I don't understand that, I will just leave it as it was")
45.         else
46.             print ("I am at, ".. x_answer_num .. ", I will remember that.")
48.         end
49.     end
50.
51.     --IS Z -
52.     print ("---")
53.     print ("Z Axis: " .. turtle_location["z"])
54.
56.
57.     if z_answer == "" then
58.         print ("Ah so I was right, good. I am at Z: ".. turtle_location["z"])
59.     else
61.         if answer_num == nil then
62.             print ("I don't understand that, I will just leave it as it was")
63.         else
64.             print ("I am at, ".. answer_num .. ", I will remember that.")
66.         end
67.     end
68.     --Is Y, Height-
69.     print ("---")
70.     print ("Y Axis: " .. turtle_location["y"])
71.
73.
74.     if y_answer == "" then
75.         print ("Ah so I was right, good. I am at Y: ".. turtle_location["y"])
76.     else
78.         if answer_num == nil then
79.             print ("I don't understand that, I will just leave it as it was")
80.         else
81.             print ("I am at, ".. answer_num .. ".")
83.         end
84.     end
85.     --Am facing? --
86.     print ("---")
87.     print ("Which way am I faceing, wright N E S W")
88.
90.
91.     if argument_4 == "N" or
92.     argument_4 == "E" or
93.     argument_4 == "S" or
94.     argument_4 == "W" then
95.         print("Facing: " .. argument_4)
96.         turtle_location["f"] = argument_4
97.     end
98.     --save it--
99.     nsp_core.serialize(turtle_location, "turtle_location")
100.     return
101. end
102.