Add files via upload
parent
0e2b22be7f
commit
92ede729fc
6
api.lua
6
api.lua
|
@ -231,7 +231,7 @@ end
|
|||
was.run=function(input,user)
|
||||
local VAR=was.user[user].global
|
||||
local state=0
|
||||
|
||||
was.username=user
|
||||
--print(dump(input))
|
||||
|
||||
for index,v in ipairs(input) do
|
||||
|
@ -246,7 +246,7 @@ was.run=function(input,user)
|
|||
elseif ndat.type=="var" and VAR[ndat.content] then
|
||||
VAR[v[i].content]=VAR[ndat.content]
|
||||
elseif ndat.type=="function" and was.functions[ndat.content] then
|
||||
VAR[v[i].content]=was.run_function(ndat.content,v,VAR,i+2,#v,{var=VAR[v[i].content],variables=VAR,user=user})
|
||||
VAR[v[i].content]=was.run_function(ndat.content,v,VAR,i+2,#v,{var=VAR[v[i].content],variables=VAR,user=user})
|
||||
else
|
||||
VAR[v[i].content]=nil
|
||||
end
|
||||
|
@ -260,6 +260,7 @@ was.run=function(input,user)
|
|||
local a
|
||||
if state==0 then
|
||||
a=was.run_function(v[i].content,v,VAR,i+1,#v,{var=VAR[v[i].content],variables=VAR,user=user})
|
||||
|
||||
end
|
||||
if v[i].content=="if" and a~=true then
|
||||
state=state+1
|
||||
|
@ -273,5 +274,6 @@ was.run=function(input,user)
|
|||
i=i+1
|
||||
end
|
||||
end
|
||||
was.username=""
|
||||
--print(dump(VAR))
|
||||
end
|
1
init.lua
1
init.lua
|
@ -4,6 +4,7 @@ was={
|
|||
info={},
|
||||
privs={},
|
||||
user={},
|
||||
username="",
|
||||
symbols={
|
||||
["!"]=function() end,
|
||||
["=="]=function() end,
|
||||
|
|
58
register.lua
58
register.lua
|
@ -1,3 +1,8 @@
|
|||
|
||||
--[[
|
||||
================= SYMBOLS =================
|
||||
--]]
|
||||
|
||||
was.register_symbol("?",
|
||||
function(data,variables,user)
|
||||
return user
|
||||
|
@ -5,6 +10,10 @@ was.register_symbol("?",
|
|||
"return username"
|
||||
)
|
||||
|
||||
--[[
|
||||
================= SERVER =================
|
||||
--]]
|
||||
|
||||
was.register_function("print",{
|
||||
privs={server=true},
|
||||
packed=true,
|
||||
|
@ -21,8 +30,12 @@ was.register_function("dump",{
|
|||
end
|
||||
})
|
||||
|
||||
--[[
|
||||
================= DATATYPES = VARIABLES =================
|
||||
--]]
|
||||
|
||||
was.register_function("pos",{
|
||||
info="to pos (n1 n2 n3)",
|
||||
info="numbers to pos (n1 n2 n3)",
|
||||
action=function(n1,n2,n3)
|
||||
if type(n1)=="number" and type(n2)=="number" and type(n3)=="number" then
|
||||
return {x=n1,y=n2,z=n3}
|
||||
|
@ -30,18 +43,51 @@ was.register_function("pos",{
|
|||
end
|
||||
})
|
||||
|
||||
|
||||
--[[
|
||||
================= NODES =================
|
||||
--]]
|
||||
|
||||
was.register_function("node.set",{
|
||||
info="(pos,nodename)",
|
||||
info="set node (pos,nodename)",
|
||||
privs={give=true,ban=true},
|
||||
action=function(pos,name)
|
||||
if was.is_string(name) and was.is_pos(pos) and minetest.registered_nodes[name] then
|
||||
if was.is_string(name) and was.is_pos(pos) and minetest.registered_nodes[name] and not minetest.is_protected(pos,was.username) then
|
||||
minetest.set_node(pos,{name=name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
was.register_function("node.add",{
|
||||
info="add node (pos,nodename)",
|
||||
privs={give=true,kick=true},
|
||||
action=function(pos,name)
|
||||
if was.is_string(name) and was.is_pos(pos) and minetest.registered_nodes[name] and not minetest.is_protected(pos,was.username) then
|
||||
minetest.add_node(pos,{name=name})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
was.register_function("node.get_name",{
|
||||
info="get node name (pos)",
|
||||
action=function(pos)
|
||||
return (was.is_pos(pos) and minetest.get_node(pos).name or nil)
|
||||
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
|
||||
})
|
||||
|
||||
--[[
|
||||
================= PLAYER =================
|
||||
--]]
|
||||
|
||||
was.register_function("player.get_pos",{
|
||||
info="(playername)",
|
||||
info="get player name (playername)",
|
||||
action=function(name)
|
||||
if type(name)~="string" then
|
||||
return
|
||||
|
@ -53,6 +99,10 @@ was.register_function("player.get_pos",{
|
|||
end
|
||||
})
|
||||
|
||||
--[[
|
||||
================= MISC =================
|
||||
--]]
|
||||
|
||||
was.register_function("if",{
|
||||
packed=true,
|
||||
info="able oparators: and or not nor == ~= < > => =<",
|
||||
|
|
Loading…
Reference in New Issue