--[[ ================= SYMBOLS ================= --]] was.register_symbol("?",function() return was.userdata.name end,"return username") was.register_symbol("!", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" ! only able in if state" end end,"Empty value") was.register_symbol(">", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" > only able in if state" end end,"Greater then (only used with if)" ) was.register_symbol("<", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" < only able in if state" end end,"Less then (only used with if)" ) was.register_symbol("<=", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" <= only able in if state" end end,"Less or equal (only used with if)" ) was.register_symbol(">=", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" >= only able in if state" end end,"Greater or equal (only used with if)" ) was.register_symbol("==", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" == only able in if state" end end,"Equal (only used with if)" ) was.register_symbol("~=", function() if was.userdata.function_name~="if" and was.userdata.function_name~="elseif" then was.userdata.error=" > only able in if state" end end,"Equal (only used with if)" ) was.register_symbol("!=",function() end, "var = nothing") was.register_symbol("--",function() end, "Comment") was.register_symbol("-",function() end, "Minus") was.register_symbol("+=",function() local i=was.userdata.index if was.is_number(was.iuserdata(i-1)) and was.is_number(was.iuserdata(i+1)) then return was.iuserdata(i-1) + was.iuserdata(i+1) end end, "var + n" ) was.register_symbol("-=",function() local i=was.userdata.index if was.is_number(was.iuserdata(i-1)) and was.is_number(was.iuserdata(i+1)) then return was.iuserdata(i-1) - was.iuserdata(i+1) end end, "var - n" ) was.register_symbol("*=",function() local i=was.userdata.index if was.is_number(was.iuserdata(i-1)) and was.is_number(was.iuserdata(i+1)) then return was.iuserdata(i-1) * was.iuserdata(i+1) end end, "var * n" ) was.register_symbol("/=",function() local i=was.userdata.index if was.is_number(was.iuserdata(i-1)) and was.is_number(was.iuserdata(i+1)) then return was.iuserdata(i-1) / was.iuserdata(i+1) end end, "var / n" ) --[[ ================= SERVER ================= --]] was.register_function("get.objects",{ info='return table of objects (pos distance <"player" or "entity" or none for both>)', action=function(pos,d,typ) if was.is_pos(pos) and was.is_number(d) then if not minetest.check_player_privs(was.userdata.name,{was=true}) and d>10 then was.userdata.error="for safety reasons is the max distance 10 without the was privilege" return end if not typ then return minetest.get_objects_inside_radius(pos, d) else local obs={} for _, ob in ipairs(minetest.get_objects_inside_radius(pos, d)) do local en=ob:get_luaentity() if (en and typ=="entity") or (not en and typ=="player") then table.insert(obs,ob) end end return obs end end end }) was.register_function("cmd",{ info='Command eg /me says... (<"commandname"> <"text" or none>)', action=function(cmd,param) param=param or "" if not ((was.is_string(cmd) or was.is_number(cmd)) and (was.is_string(param) or was.is_number(param))) then return end local c=minetest.registered_chatcommands[cmd] if not c then return end local p1=minetest.check_player_privs(was.userdata.name, c.privs) local msg="" local a if not p1 then msg="You aren't' allowed to do that" elseif c then a,msg=c.func(was.userdata.name,param) msg=msg or "" minetest.chat_send_player(was.userdata.name,msg) end return msg end }) was.register_function("get.gametime",{ info="Get gametime ()", action=function() return minetest.get_gametime() end }) --[[ ================= DATATYPES = VARIABLES ================= --]] was.register_function("math.percent",{ info="return percent of number (n1 n2)", action=function(a,b) if was.is_number(a) and was.is_number(b) then return (a / b) *100 end end }) was.register_function("math.random",{ info="random number (num1 num2)", action=function(a,b) if was.is_number(a) and was.is_number(b) and a50 then was.userdata.error="for safety reasons is the max distance 50 without the was privilege" return end local n=minetest.registered_nodes[minetest.get_node(pos).name] if n and n.buildable_to==false then return end local inv=minetest.get_meta(was.userdata.pos):get_inventory() if not inv:contains_item("storage",name) then return end inv:remove_item("storage",name) minetest.set_node(pos,{name=name}) end end }) was.register_function("node.remove",{ info="remove node (pos)", action=function(pos) if was.is_pos(pos) and not minetest.is_protected(pos,was.userdata.name) then if not minetest.check_player_privs(was.userdata.name,{was=true}) and vector.distance(was.userdata.pos,pos)>30 then was.userdata.error="for safety reasons is the max distance 30 without the was privilege" return end local n=minetest.registered_nodes[minetest.get_node(pos).name] local player=minetest.get_player_by_name(was.userdata.name) if n and ((n.can_dig and player and n.can_dig(pos, player)==false) or (n.pointable==false) or n.drop=="") then return end minetest.get_meta(was.userdata.pos):get_inventory():add_item("storage",minetest.get_node(pos).name) minetest.remove_node(pos) end end }) was.register_function("node.set_param",{ info="Set node param (pos,number)", action=function(pos,p) if was.is_pos(pos) and was.is_number(p) and not was.protected(pos) then minetest.swap_node(pos,{name=minetest.get_node(pos).name,param2=p}) end end }) was.register_function("node.get_param",{ info="Get node param (pos)", action=function(pos) if was.is_pos(pos) then return minetest.get_node(pos).param2 end end }) was.register_function("node.get_name",{ info="get node name (pos)", action=function(pos) if was.is_pos(pos) then return minetest.get_node(pos).name end end }) was.register_function("node.exist",{ info="node exist (name)", action=function(name) return ((was.is_string(name) or nil) and minetest.registered_nodes[name]~=nil) end }) --[[ ================= NODEE=META ================= --]] was.register_function("nodemeta.set_int",{ privs={was=true}, info="Set node meta (pos name number)", action=function(pos,na,n) if was.is_pos(pos) and was.is_string(na) and was.is_number(n) then minetest.get_meta(pos):set_int(na,n) end end }) was.register_function("nodemeta.get_int",{ privs={was=true}, info="Get node meta (pos name)", action=function(pos,na) if was.is_pos(pos) and was.is_string(na) then return minetest.get_meta(pos):get_int(na) end end }) was.register_function("nodemeta.set_string",{ privs={was=true}, info="Set node meta (pos name string)", action=function(pos,na,n) if was.is_pos(pos) and was.is_string(na) and was.is_string(n) then minetest.get_meta(pos):set_string(na,n) end end }) was.register_function("nodemeta.get_string",{ privs={was=true}, info="Get node meta (pos name)", action=function(pos,na) if was.is_pos(pos) and was.is_string(na) then return minetest.get_meta(pos):get_string(na) end end }) was.register_function("nodetimer.start",{ privs={was=true}, info="Start node timer (