· 6 years ago · Dec 27, 2019, 09:56 PM
1local requiredAPIVersion = 2.42
2
3pcall(dofile,"scripts/ssccssccAPI.lua")
4
5if not interface_s or interface_s.Version < requiredAPIVersion then
6
7 if tpt.confirm("Download and install file", "Interface API is required to run script. Download it now?") then
8
9 fs.makeDirectory("scripts")
10
11 tpt.getscript(172, "scripts/ssccssccAPI.lua", 1, 0)
12
13 else
14
15 tpt.log("Script is unavailable due to lack of required files.")
16
17 end
18
19end
20
21local DefaultTheme = interface_s.DefaultTheme
22
23local MainWindow
24
25local stkm_direction_y = "hover"
26
27local stkm_direction_x = "none"
28
29local stkm_id
30
31function setupInterface()
32
33 MainWindow = interface_s.Components.Window:new(40, 40, 150, 50,true, DefaultTheme.Window)
34
35 MainWindow.AllowResize = false
36
37 MainWindow.AlwaysFocused = true
38
39 local idLabel = interface_s.Components.Label:new(6, 12, "Id: ", DefaultTheme.Label)
40
41 local idText = interface_s.Components.Textbox:new(35, 10, 50, 12, DefaultTheme.Textbox)
42
43 local idButton = interface_s.Components.Button:new(95, 32, 50, 12, "Submit", DefaultTheme.Button)
44
45 idButton:AddHint("Submit ID")
46
47 local powerLabel = interface_s.Components.Label:new(6, 12, "Item: ", DefaultTheme.Label)
48
49 local powerSelect = interface_s.Components.Combobox:new(35, 10, 50, 12, {"Fly", "Teleport"}, DefaultTheme.Combobox)
50
51 local powerButton = interface_s.Components.Button:new(95, 32, 50, 12, "Select", DefaultTheme.Button)
52
53 powerButton:AddHint("Give Power")
54
55 idButton.OnPressed = function ()
56
57 stkm_id = tonumber(idText.Text)
58
59 idLabel:Hide()
60
61 idText:Hide()
62
63 idButton:Hide()
64
65 powerLabel:Show()
66
67 powerText:Show()
68
69 powerButton:Show()
70
71 end
72
73 powerButton.OnPressed = function ()
74
75 if powerSelect.Items[powerSelect.SelectedIndex + 1] == "Flight" then
76
77 if stkm_direction_y == "up" then
78
79 sim.partProperty(stkm_id, "vy", -3)
80
81 end
82
83 if stkm_direction_x == "left" then
84
85 sim.partProperty(stkm_id, "vx", -1.5)
86
87 end
88
89 if stkm_direction_x == "right" then
90
91 sim.partProperty(stkm_id, "vx", 1.5)
92
93 end
94
95 end
96
97 end
98
99 local exitButton = interface_s.Components.Button:new(142, 0, 8, 8, "x", DefaultTheme.Button)
100
101 exitButton.OnPressed = (function ()
102
103 interface_s.RemoveComponent(MainWindow)
104
105 end)
106
107 MainWindow:AddComponent(idLabel)
108
109 MainWindow:AddComponent(idSelect)
110
111 MainWindow:AddComponent(idButton)
112
113 MainWindow:AddComponent(powerLabel)
114
115 MainWindow:AddComponent(powerSelect)
116
117 MainWindow:AddComponent(powerButton)
118
119 MainWindow:AddComponent(exitButton)
120
121 powerLabel:Hide()
122
123 powerText:Hide()
124
125 powerButton:Hide()
126
127end
128
129setupInterface()
130
131event.register(event.keypress, function (key, scan, rep, shift, ctrl, alt)
132
133 if scan == 13 and ctrl == true then
134
135 interface_s.addComponent(MainWindow)
136
137 end
138
139 if scan == 82 then
140
141 stkm_direction_y = "up"
142
143 end
144
145 if scan == 80 then
146
147 stkm_direction_x = "left"
148
149 end
150
151 if scan == 79 then
152
153 stkm_direction_x = "right"
154
155 end
156
157end)
158
159event.register(event.keyrelease, function (key, scan, rep, shift, ctrl, alt)
160
161 if scan == 82 then
162
163 stkm_direction_y = "none"
164
165 end
166
167 if scan == 80 then
168
169 stkm_direction_x = "none"
170
171 end
172
173 if scan == 79 then
174
175 stkm_direction_x = "none"
176
177 end
178
179end)