Add files via upload

master
AiTechEye 2019-01-15 13:47:15 +01:00 committed by GitHub
parent de45d37fd3
commit 9f20155ae6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 109 additions and 22 deletions

View File

@ -17,8 +17,17 @@ was.runcmd=function(cmd,name,param)
return msg
end
was.send=function(pos,channel,msg,from_channel)
local na=pos.x .."." .. pos.y .."." ..pos.z
if not was.wire_signals[na] then
was.wire_signals[na]={jobs={[na]=pos},msg=msg,channel=channel,from_channel=from_channel}
was.wire_leading()
end
end
was.get_node=function(pos)
was.get_node=function(pos,wire)
local n=minetest.get_node(pos).name
if n=="ignore" then
local vox=minetest.get_voxel_manip()
@ -33,17 +42,18 @@ end
was.wire_leading=function()
local counts=0
local po={{0,0,0},{-1,0,0},{1,0,0},{0,0,-1},{0,0,1},{0,-1,0},{0,1,0}}
for i, a in pairs(was.wire_signals) do
local c=0
for xyz, pos in pairs(a.jobs) do
for ii, p in pairs(po) do
for ii, p in pairs(was.wire_rules) do
local n={x=pos.x+p[1],y=pos.y+p[2],z=pos.z+p[3]}
local s=n.x .. "." .. n.y .."." ..n.z
local na=was.get_node(n)
if not a.jobs[s] and minetest.get_item_group(na,"was_wire")>0 then
a.jobs[s]=n
c=c+1
minetest.set_node(n,{name="was:wire",param2=3})
minetest.get_node_timer(pos):start(0.1)
elseif not a.jobs[s] and minetest.get_item_group(na,"was_unit")>0 and minetest.registered_nodes[na].on_waswire then
minetest.registered_nodes[na].on_waswire(n,a.channel,a.from_channel,a.msg)
a.jobs[s]=n

31
gui.lua
View File

@ -7,6 +7,7 @@ was.gui=function(name,msg)
local funcs=""
local funcs2cho={}
local symbs="SYMBOLS,"
local tx=17
local console=""
@ -24,6 +25,7 @@ was.gui=function(name,msg)
for _,v in pairs(was.function_list) do
if minetest.check_player_privs(name,was.privs[v]) then
funcs=funcs .. v ..","
table.insert(funcs2cho,v)
end
end
@ -55,8 +57,10 @@ was.gui=function(name,msg)
.."tooltip[pupos;Press Enter and punch on a node to return the position, or punch it again to get its name, Press Enter to move the text to the textarea]"
.."tooltip[bg;Background]"
.."tooltip[console;Console]"
.."tooltip[channel;Channel]"
.."tooltip[channel;Channel (Press save to change)]"
was.user[name].punchpos=nil
was.user[name].funcs=funcs2cho
minetest.after(0.1, function(gui,name)
return minetest.show_formspec(name, "was.gui",gui)
@ -70,7 +74,7 @@ minetest.register_on_player_receive_fields(function(user, form, pressed)
if (pressed.quit and not pressed.key_enter) or not was.user[name] then
if was.user[name] then
was.user[name].text=nil
was.user[name].show_print=nil
was.user[name].funcs=nil
was.user[name].channel=nil
end
return
@ -127,7 +131,7 @@ minetest.register_on_player_receive_fields(function(user, form, pressed)
if pressed.list and pressed.list~="IMV" then
local n=pressed.list:gsub("CHG:","")
local f=was.function_list[tonumber(n)]
local f=was.user[name].funcs[tonumber(n)]
local info=was.info[f] or ""
if was.privs[f] then
info=info .. "| Privs: " ..minetest.privs_to_string(was.privs[f])
@ -179,6 +183,27 @@ minetest.register_on_player_receive_fields(function(user, form, pressed)
was.gui(name,msg)
return
end
elseif form=="was.channel" then
local name=user:get_player_name()
if was.user[name] and pressed.channel then
minetest.get_meta(was.user[name]):set_string("channel",pressed.channel)
end
was.user[name]=nil
elseif form=="was.channel+channelto" then
local name=user:get_player_name()
if was.user[name] then
local m=minetest.get_meta(was.user[name])
if pressed.channel==m:get_string("channelto") or pressed.channelto==m:get_string("channel") then
return
end
if pressed.channel then
m:set_string("channel",pressed.channel)
end
if pressed.channelto then
m:set_string("channelto",pressed.channelto)
end
end
was.user[name]=nil
end
end)

View File

@ -9,6 +9,7 @@ was={
symbols={},
wire_signals={},
symbols_characters=".#@=?!&{}%*+-/$<>|~^",
wire_rules={{0,0,0},{-1,0,0},{1,0,0},{0,0,-1},{0,0,1},{0,-1,0},{0,1,0}},
}
dofile(minetest.get_modpath("was") .. "/api.lua")

View File

@ -20,7 +20,11 @@ minetest.register_node("was:computer", {
},
groups = {oddly_breakable_by_hand = 3,was_unit=1,tubedevice = 1, tubedevice_receiver = 1},
on_punch = function(pos, node, player, pointed_thing)
minetest.swap_node(pos,{name="was:computer_closed",param2=node.param2})
local meta=minetest.get_meta(pos)
local name=player:get_player_name() or ""
if meta:get_string("owner")==name or minetest.check_player_privs(name, {protection_bypass=true}) then
minetest.swap_node(pos,{name="was:computer_closed",param2=node.param2})
end
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
@ -68,7 +72,7 @@ minetest.register_node("was:computer", {
on_waswire=function(pos,channel,from_channel,msg)
local meta=minetest.get_meta(pos)
local user=meta:get_string("owner")
if user~="" and channel==meta:get_string("channel") then
if user~="" and channel==meta:get_string("channel") and from_channel~=meta:get_string("channel") then
was.compiler(minetest.deserialize(meta:get_string("text")),{
type="node",
user=user,
@ -175,11 +179,12 @@ minetest.register_node("was:computer_closed", {
minetest.register_node("was:wire", {
description = "was wire",
tiles = {
"was_guibg.png^[colorize:#FFFFFF",
},
tiles = {{name="was_wire.png"}}, --,color=0xffffffff
drop="was:wire",
drawtype="nodebox",
paramtype = "light",
paramtype2="colorwallmounted",
palette="was_palette.png",
sunlight_propagates=true,
walkable=false,
node_box = {
@ -193,14 +198,61 @@ minetest.register_node("was:wire", {
},
connects_to={"group:was_wire","group:was_unit"},
groups = {dig_immediate = 3,was_wire=1},
on_construct = function(pos)
if minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name,"was_wire")>0 then
-- minetest.swap_node(pos,{name="was:wire_up"})
elseif minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name,"was_wire")>0 then
-- minetest.swap_node(pos,{name="was:wire_down"})
--on_rightclick = function(pos, node, player, itemstack, pointed_thing)
-- node.param2=node.param2+1
-- print(node.param2)
-- minetest.swap_node(pos,node)
--end,
after_place_node = function(pos, placer)
minetest.set_node(pos,{name="was:wire",param2=135})
end,
on_timer = function (pos, elapsed)
minetest.swap_node(pos,{name="was:wire",param2=135})
end,
})
minetest.register_node("was:touchscreen", {
description = "Touchscreen",
tiles = {"was_touchscreen.png"},
drawtype="nodebox",
paramtype = "light",
paramtype2="facedir",
node_box = {
type = "fixed",
fixed = {
{-0.15, -0.25, 0.45, 0.15, 0.25, 0.5},
}
},
groups = {oddly_breakable_by_hand = 3,was_unit=1},
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,1.5]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+channelto",gui)
end, gui,name)
else
was.send(pos,meta:get_string("channelto"),name,meta:get_string("channel"))
end
end,
on_punch = function(pos, node, player, pointed_thing)
local meta = minetest.get_meta(pos)
local name=player:get_player_name() or ""
was.send(pos,meta:get_string("channelto"),name,meta:get_string("channel"))
end,
on_waswire=function(pos,channel,from_channel,msg)
local meta=minetest.get_meta(pos)
local user=meta:get_string("owner")
if channel==meta:get_string("channel") and (was.is_string(msg) or was.is_number(msg)) then
meta:set_string("infotext",msg)
end
end,
on_destruct = function(pos)
--minetest.check_for_falling(pos)
end
})

View File

@ -232,7 +232,7 @@ was.register_function("table.length",{
end
})
was.register_function("table.merge",{
was.register_function("merge",{
info="Merge variables and datatypes (s1 n1 s...) or (table table2 s n)",
packed=true,
action=function(a)
@ -780,8 +780,7 @@ was.register_function("was.send",{
if nchannel==channel then
was.userdata.error="can't send to same channel"
else
table.insert(was.wire_signals,{count=1,jobs={[p.x .."." .. p.y .."." ..p.z]=p},msg=msg,channel=channel,from_channel=nchannel})
was.wire_leading()
was.send(p,channel,msg,nchannel)
end
end
end