@@ -187,17 +187,62 @@ local create_environment = function(pos, mem, event)
187
187
vports = {a = vports .a , b = vports .b , c = vports .c , d = vports .d }
188
188
local rports = get_real_portstates (pos )
189
189
190
- return { print = safeprint ,
190
+ return {
191
+ print = safeprint ,
191
192
pin = merge_portstates (vports , rports ),
192
193
port = vports ,
193
194
interrupt = getinterrupt (pos ),
194
195
digiline_send = getdigiline_send (pos ),
195
196
mem = mem ,
196
197
tostring = tostring ,
197
198
tonumber = tonumber ,
198
- string = tablecopy (string ),
199
- math = tablecopy (math ),
200
- event = event }
199
+ string = {
200
+ byte = string.byte ,
201
+ char = string.char ,
202
+ find = string.find ,
203
+ format = string.format ,
204
+ gmatch = string.gmatch ,
205
+ gsub = string.gsub ,
206
+ len = string.len ,
207
+ lower = string.lower ,
208
+ match = string.match ,
209
+ rep = string.rep ,
210
+ reverse = string.reverse ,
211
+ sub = string.sub ,
212
+ },
213
+ math = {
214
+ abs = math.abs ,
215
+ acos = math.acos ,
216
+ asin = math.asin ,
217
+ atan = math.atan ,
218
+ atan2 = math.atan2 ,
219
+ ceil = math.ceil ,
220
+ cos = math.cos ,
221
+ cosh = math.cosh ,
222
+ deg = math.deg ,
223
+ exp = math.exp ,
224
+ floor = math.floor ,
225
+ fmod = math.fmod ,
226
+ frexp = math.frexp ,
227
+ huge = math.huge ,
228
+ ldexp = math.ldexp ,
229
+ log = math.log ,
230
+ log10 = math.log10 ,
231
+ max = math.max ,
232
+ min = math.min ,
233
+ modf = math.modf ,
234
+ pi = math.pi ,
235
+ pow = math.pow ,
236
+ rad = math.rad ,
237
+ random = math.random ,
238
+ sin = math.sin ,
239
+ sinh = math.sinh ,
240
+ sqrt = math.sqrt ,
241
+ tan = math.tan ,
242
+ tanh = math.tanh ,
243
+ },
244
+ event = event ,
245
+ }
201
246
end
202
247
203
248
local create_sandbox = function (code , env )
@@ -223,14 +268,6 @@ local do_overheat = function (pos, meta)
223
268
end
224
269
end
225
270
226
- local tablecopy = function (t )
227
- local tnew = {}
228
- for key , value in pairs (t ) do
229
- tnew [key ] = value
230
- end
231
- return tnew
232
- end
233
-
234
271
local load_memory = function (meta )
235
272
return minetest .deserialize (meta :get_string (" lc_memory" )) or {}
236
273
end
0 commit comments