Add files via upload

master
AiTechEye 2019-01-18 22:23:50 +01:00 committed by GitHub
parent 611664d97b
commit 1469a7c964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 204 additions and 30 deletions

View File

@ -7,7 +7,25 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "was:mdoid_gate",
recipe = {
{"was:plastic_piece","was:wire","was:plastic_piece"},
{"was:plastic_piece","was:wire","was:plastic_piece"},
{"","",""},
}
})
minetest.register_craft({
output = "was:digiline_was_converter",
recipe = {
{"digilines:wire_std_00000000","",""},
{"was:sender","",""},
{"was:wire","",""},
}
})
--[[ currently broken
minetest.register_craft({
output = "was:router",
recipe = {
@ -16,6 +34,7 @@ minetest.register_craft({
{"was:plastic_piece","was:wire","was:plastic_piece"},
}
})
--]]
minetest.register_craft({
output = "was:sender",

View File

@ -46,7 +46,6 @@ was.send=function(pos,channel,msg,from_channel)
if was.wire_sends.times>50 then
return
end
end
was.wire_signals[na]={jobs={[na]=pos},msg=msg,channel=channel,from_channel=from_channel}
minetest.after(0, function()
@ -55,6 +54,14 @@ was.send=function(pos,channel,msg,from_channel)
end
end
was.send_wireless=function(pos,channel,msg,from_channel,radius)
for _,p in pairs(minetest.find_nodes_in_area(vector.add(pos,radius),vector.subtract(pos,radius),"group:was_unit")) do
if minetest.get_item_group(was.get_node(p),"was_resender")==0 and not vector.equals(pos,p) then
was.send(p,channel,msg,from_channel)
end
end
end
was.get_node=function(pos,wire)
local n=minetest.get_node(pos).name
if n=="ignore" then
@ -73,22 +80,26 @@ was.wire_leading=function()
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(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
if minetest.registered_nodes[na].on_waswire then
minetest.registered_nodes[na].on_waswire(n,a.channel,a.from_channel,a.msg)
if not pos.ignore then
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] then
if minetest.get_item_group(na,"was_wire")>0 then
a.jobs[s]=n
c=c+1
minetest.swap_node(n,{name=na,param2=3})
minetest.get_node_timer(n):start(0.1)
if minetest.registered_nodes[na].on_waswire then
minetest.registered_nodes[na].on_waswire(n,a.channel,a.from_channel,a.msg)
end
elseif 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]={ignore=true}
c=c+1
end
end
minetest.swap_node(n,{name=na,param2=3})
minetest.get_node_timer(n):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
c=c+1
end
end
end

17
gui.lua
View File

@ -189,12 +189,6 @@ minetest.register_on_player_receive_fields(function(user, form, pressed)
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])
@ -207,6 +201,17 @@ minetest.register_on_player_receive_fields(function(user, form, pressed)
if pressed.channelto then
m:set_string("channelto",pressed.channelto)
end
if pressed.radius then
local nu=tonumber(pressed.radius)
if nu then
if nu>10 then
nu=10
elseif nu<0 then
nu=0
end
m:set_int("radius",nu)
end
end
end
was.user[name]=nil
end

121
items.lua
View File

@ -197,6 +197,8 @@ minetest.register_node("was:computer_closed", {
minetest.register_node("was:wire", {
description = "was wire",
tiles = {{name="was_wire.png"}},
inventory_image="was_wire_pre.png",
wield_image="was_wire_pre.png",
drop="was:wire",
drawtype="nodebox",
paramtype = "light",
@ -229,7 +231,7 @@ minetest.register_node("was:wire", {
})
minetest.register_node("was:touchscreen", {
description = "Touchscreen",
description = "Touchscreen (wireless)",
tiles = {"was_touchscreen.png"},
drawtype="nodebox",
paramtype = "light",
@ -250,11 +252,13 @@ minetest.register_node("was:touchscreen", {
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") .."]"
local gui="size[2.5,2.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") .."]"
.."field[0,2.3;3,1;radius;Radius;" .. meta:get_int("radius") .."]"
was.user[name]=pos
minetest.after(0.1, function(gui,name)
return minetest.show_formspec(name, "was.channel+channelto",gui)
return minetest.show_formspec(name, "was.channel",gui)
end, gui,name)
else
was.send(pos,meta:get_string("channelto"),name,meta:get_string("channel"))
@ -281,7 +285,6 @@ minetest.register_node("was:router", {
paramtype = "light",
paramtype2="facedir",
node_box = {
--type = "fixed",
type = "connected",
connect_back={-0.05,-0.5,0, 0.05,-0.45,0.5},
connect_front={-0.05,-0.5,-0.5, 0.05,-0.45,0},
@ -297,8 +300,10 @@ minetest.register_node("was:router", {
connects_to={"group:was_wire","group:was_unit"},
groups = {oddly_breakable_by_hand = 3,was_unit=1},
on_waswire=function(pos,channel,from_channel,msg)
for _,p in pairs(minetest.find_nodes_in_area(vector.add(pos,10),vector.subtract(pos,10),"group:was_unit")) do
if was.get_node(p)~="was:router" then
local r = minetest.get_meta(pos):get_int("radius")
for _,p in pairs(minetest.find_nodes_in_area(vector.add(pos,r),vector.subtract(pos,r),"group:was_unit")) do
local na=was.get_node(p)
if na~="was:router" and minetest.get_item_group(na,"was_resender")==0 then
was.send(p,channel,msg,from_channel)
end
end
@ -306,6 +311,21 @@ minetest.register_node("was:router", {
on_timer = function (pos, elapsed)
minetest.swap_node(pos,{name="was:wire",param2=135})
end,
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name() or "")
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 then
local gui="size[2.5,0.7]field[0,0.5;3,1;radius;Radius;" .. meta:get_int("radius") .."]"
was.user[name]=pos
minetest.after(0.1, function(gui,name)
return minetest.show_formspec(name, "was.channel",gui)
end, gui,name)
end
end,
})
minetest.register_node("was:sender", {
@ -330,7 +350,8 @@ minetest.register_node("was:sender", {
connects_to={"group:was_wire","group:was_unit"},
groups = {oddly_breakable_by_hand = 3,was_wire=1},
on_waswire=function(pos,channel,from_channel,msg)
for _,p in pairs(minetest.find_nodes_in_area(vector.add(pos,10),vector.subtract(pos,10),"was:receiver")) do
local r = minetest.get_meta(pos):get_int("radius")
for _,p in pairs(minetest.find_nodes_in_area(vector.add(pos,r),vector.subtract(pos,r),"was:receiver")) do
was.send(p,channel,msg,from_channel)
minetest.swap_node(p,{name="was:receiver",param2=3})
minetest.get_node_timer(p):start(0.1)
@ -341,6 +362,19 @@ minetest.register_node("was:sender", {
end,
after_place_node = function(pos, placer)
minetest.set_node(pos,{name="was:sender",param2=135})
local meta = minetest.get_meta(pos)
meta:set_string("owner",placer:get_player_name() or "")
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 then
local gui="size[2.5,0.7]field[0,0.5;3,1;radius;Radius;" .. meta:get_int("radius") .."]"
was.user[name]=pos
minetest.after(0.1, function(gui,name)
return minetest.show_formspec(name, "was.channel",gui)
end, gui,name)
end
end,
})
@ -372,4 +406,77 @@ minetest.register_node("was:receiver", {
after_place_node = function(pos, placer)
minetest.set_node(pos,{name="was:receiver",param2=135})
end,
})
if minetest.get_modpath("digilines") then
minetest.register_node("was:digiline_was_converter", {
description = "digiline/was converter",
tiles = {{name="was_wire.png"}},
drop="was:digiline_was_converter",
drawtype="nodebox",
paramtype = "light",
palette="was_palette.png",
paramtype2="colorwallmounted",
node_box = {
type = "connected",
connect_back={-0.05,-0.5,0, 0.05,-0.45,0.5},
connect_front={-0.05,-0.5,-0.5, 0.05,-0.45,0},
connect_left={-0.5,-0.5,-0.05, 0.05,-0.45,0.05},
connect_right={0,-0.5,-0.05, 0.5,-0.45,0.05},
connect_top = {-0.05, -0.5, -0.05, 0.05, 0.5, 0.05},
fixed = {
{-0.25, -0.5, -0.25, 0.25, -0.3, 0.25},
}
},
connects_to={"group:was_wire","group:was_unit","group:dig_immediate"},
groups = {oddly_breakable_by_hand = 3,was_wire=1},
on_timer = function (pos, elapsed)
minetest.swap_node(pos,{name="was:digiline_was_converter",param2=135})
end,
after_place_node = function(pos, placer)
minetest.set_node(pos,{name="was:digiline_was_converter",param2=135})
end,
on_waswire=function(pos,channel,from_channel,msg)
digilines.receptor_send(pos,digilines.rules.default,channel,msg)
end,
digiline = {
receptor={},
effector = {
action = function (pos,node,channel,msg)
was.send(pos,channel,msg)
end,
}
},
})
end
minetest.register_node("was:mdoid_gate", { --x+ 1 x- 3 z+ 0 z- 2
description = "Wire multy doidgate",
tiles = {"was_mdoidgate.png","was_wire.png","was_wire.png","was_wire.png","was_wire.png","was_wire.png"},
drawtype="nodebox",
paramtype = "light",
paramtype2="facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.4, 0.5},
}
},
groups = {oddly_breakable_by_hand = 3,was_unit=1,was_resender=1},
on_waswire=function(pos,channel,from_channel,msg)
local p=minetest.get_node(pos).param2
local np={x=pos.x,y=pos.y,z=pos.z}
if p==1 then
np.x=np.x+1
elseif p==3 then
np.x=np.x-1
elseif p==0 then
np.z=np.z+1
elseif p==2 then
np.z=np.z-1
end
if minetest.get_item_group(minetest.get_node(np).name,"was_wire")>0 and not vector.equals(pos,np) then
was.send(np,channel,msg,from_channel)
end
end,
})

View File

@ -272,6 +272,14 @@ was.register_function("pos",{
end
})
was.register_function("epos",{
info="Equals/same pos (pos1 pos2)",
action=function(p1,p2)
if was.is_pos(p1) and was.is_pos(p2) then
return vector.equals(p1,p2)
end
end
})
--[[
================= NODES =================
@ -807,4 +815,28 @@ was.register_function("was.send",{
end
end
end
})
})
--[[
currently broken
was.register_function("was.send_wireless",{
info="Send data through wires (string_channel msg radius) max radius is 10",
action=function(channel,msg,radius)
local p=was.userdata.pos
if p and was.is_string(channel) and (not radius or was.is_number(radius)) then
radius=radius or 3
if radius>10 then radius=10 end
local meta = minetest.get_meta(p)
local nchannel=meta:get_string("channel")
if nchannel==channel then
was.userdata.error="can't send to same channel"
else
was.send(p,channel,msg,nchannel)
was.send_wireless(p,channel,msg,nchannel,radius)
end
end
end
})
--]]