Add files via upload
parent
8ad915d945
commit
ef5a025e77
23
api.lua
23
api.lua
|
@ -239,7 +239,15 @@ was.compiler=function(input_text,def)
|
||||||
end
|
end
|
||||||
nexts=0
|
nexts=0
|
||||||
data[ii].forstate=true
|
data[ii].forstate=true
|
||||||
|
elseif data[ii].type=="var" and data[ii].content=="break" then
|
||||||
|
--break
|
||||||
|
if nexts==0 then
|
||||||
|
return 'ERROR line '.. i ..': no "for" to break'
|
||||||
|
end
|
||||||
|
data[ii].forstate=true
|
||||||
|
elseif data[ii].type=="var" and data[ii].content=="return" then
|
||||||
|
--return
|
||||||
|
data[ii].function_return=true
|
||||||
elseif data[ii+1] and data[ii+2] and data[ii].type=="var" and data[ii+1].content=="." and (data[ii+2].type=="var" or data[ii+2].type=="number") then
|
elseif data[ii+1] and data[ii+2] and data[ii].type=="var" and data[ii+1].content=="." and (data[ii+2].type=="var" or data[ii+2].type=="number") then
|
||||||
--table
|
--table
|
||||||
data[ii].table=data[ii+2].content
|
data[ii].table=data[ii+2].content
|
||||||
|
@ -424,10 +432,17 @@ was.run=function(input,def,VAR)
|
||||||
|
|
||||||
if was.userdata.error then
|
if was.userdata.error then
|
||||||
return 'ERROR line '.. index ..': ' .. was.userdata.error,def,VAR
|
return 'ERROR line '.. index ..': ' .. was.userdata.error,def,VAR
|
||||||
elseif v[i].forstate then
|
elseif state==0 and v[i].function_return then
|
||||||
if v[i].content=="next" then
|
was.userdata={}
|
||||||
|
return "",def,VAR
|
||||||
|
elseif state==0 and v[i].forstate then
|
||||||
|
if forstate and forstate.br and v[i].content=="break" then
|
||||||
|
index=forstate.br
|
||||||
|
forstate=nil
|
||||||
|
elseif v[i].content=="next" then
|
||||||
|
forstate.br=index+1
|
||||||
if forstate.i<forstate.e then
|
if forstate.i<forstate.e then
|
||||||
|
forstate.br=index
|
||||||
index=forstate.re
|
index=forstate.re
|
||||||
forstate.i=forstate.i+1
|
forstate.i=forstate.i+1
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "was:olgate",
|
||||||
|
recipe = {
|
||||||
|
{"was:chemical_lump","was:chemical_lump","was:chemical_lump"},
|
||||||
|
{"group:tree","default:copper_lump","group:tree"},
|
||||||
|
{"group:tree","default:tin_ingot","group:tree"},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "was:chemical_lump 3",
|
output = "was:chemical_lump 3",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
38
items.lua
38
items.lua
|
@ -479,4 +479,42 @@ minetest.register_node("was:mdoid_gate", { --x+ 1 x- 3 z+ 0 z- 2
|
||||||
was.send(np,channel,msg,from_channel)
|
was.send(np,channel,msg,from_channel)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("was:olgate",{
|
||||||
|
description = "On load gate (activated when loaded)",
|
||||||
|
tiles = {"was_wire.png"},
|
||||||
|
groups = {oddly_breakable_by_hand = 3,was_unit=1,was_lbm=1},
|
||||||
|
on_wasload=function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
was.send(pos,meta:get_string("channelto"),"loaded",meta:get_string("channel"))
|
||||||
|
end,
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("owner",placer:get_player_name() or "")
|
||||||
|
meta:set_string("channel", pos.x .." " ..pos.y .." " ..pos.z)
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local name=player:get_player_name() or ""
|
||||||
|
if meta:get_string("owner")==name and not player:get_player_control().aux1 then
|
||||||
|
local gui="size[2.5,2]"
|
||||||
|
.."field[0,0.3;3,1;channel;Channel;" .. meta:get_string("channel") .."]"
|
||||||
|
.."field[0,1.3;3,1;channelto;Send to channel;" .. meta:get_string("channelto") .."]"
|
||||||
|
was.user[name]=pos
|
||||||
|
minetest.after(0.1, function(gui,name)
|
||||||
|
return minetest.show_formspec(name, "was.channel",gui)
|
||||||
|
end, gui,name)
|
||||||
|
else
|
||||||
|
was.send(pos,meta:get_string("channelto"),name,meta:get_string("channel"))
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
minetest.register_lbm({
|
||||||
|
name="was:lbm",
|
||||||
|
nodenames={"group:was_lbm"},
|
||||||
|
run_at_every_load=true,
|
||||||
|
action=function(pos,node)
|
||||||
|
minetest.registered_nodes[node.name].on_wasload(pos)
|
||||||
|
end
|
||||||
})
|
})
|
|
@ -127,6 +127,14 @@ was.register_function("math.percent",{
|
||||||
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 a<b then
|
||||||
|
return math.random(a,b)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
was.register_function("math.pi",{
|
was.register_function("math.pi",{
|
||||||
info="return Pi",
|
info="return Pi",
|
||||||
|
|
Loading…
Reference in New Issue