Add control panel
3
README
@ -4,7 +4,8 @@ Digilines Stuff
|
|||||||
|
|
||||||
License:
|
License:
|
||||||
Code - LGPL v3 or later (contains some code from mesecons and digilines)
|
Code - LGPL v3 or later (contains some code from mesecons and digilines)
|
||||||
Textures - CC BY-SA 3.0 Generic (contains modified versions of textures from mesecons and digilines)
|
Textures WITHOUT "adwaita" in the file name - CC BY-SA 3.0 Generic (contains modified versions of textures from mesecons and digilines)
|
||||||
|
Textures WITH "adwaita" in the file name - These are icons by the GNOME Project, licensed under GNU LGPL v3 or CC BY-SA 3.0.
|
||||||
|
|
||||||
|
|
||||||
Depends:
|
Depends:
|
||||||
|
90
init.lua
@ -1,5 +1,52 @@
|
|||||||
digistuff = {}
|
digistuff = {}
|
||||||
|
|
||||||
|
digistuff.update_panel_formspec = function (pos,dispstr)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local fs = "size[10,8]"..
|
||||||
|
"background[0,0;0,0;digistuff_panel_bg.png;true]"..
|
||||||
|
"label[0,0;%s]"..
|
||||||
|
"image_button[2,4.5;1,1;digistuff_adwaita_go-up.png;up;]"..
|
||||||
|
"image_button[1,5;1,1;digistuff_adwaita_go-previous.png;left;]"..
|
||||||
|
"image_button[3,5;1,1;digistuff_adwaita_go-next.png;right;]"..
|
||||||
|
"image_button[2,5.5;1,1;digistuff_adwaita_go-down.png;down;]"..
|
||||||
|
"image_button[1,6.5;1,1;digistuff_adwaita_edit-undo.png;back;]"..
|
||||||
|
"image_button[3,6.5;1,1;digistuff_adwaita_emblem-default.png;enter;]"..
|
||||||
|
"field[6,5.75;2,1;channel;Channel;${channel}]"..
|
||||||
|
"button[8,5.5;1,1;savechan;Set]"
|
||||||
|
fs = fs:format(minetest.formspec_escape(dispstr))
|
||||||
|
meta:set_string("formspec",fs)
|
||||||
|
end
|
||||||
|
|
||||||
|
digistuff.panel_on_digiline_receive = function (pos, node, channel, msg)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local setchan = meta:get_string("channel")
|
||||||
|
if channel ~= setchan then return end
|
||||||
|
if type(msg) ~= "string" then return end
|
||||||
|
digistuff.update_panel_formspec(pos,msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
digistuff.panel_on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local setchan = meta:get_string("channel")
|
||||||
|
if fields.savechan then
|
||||||
|
meta:set_string("channel",fields.channel)
|
||||||
|
local helpmsg = "Channel has been set. Waiting for data..."
|
||||||
|
digistuff.update_panel_formspec(pos,helpmsg)
|
||||||
|
elseif fields.up then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "up")
|
||||||
|
elseif fields.down then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "down")
|
||||||
|
elseif fields.left then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "left")
|
||||||
|
elseif fields.right then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "right")
|
||||||
|
elseif fields.back then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "back")
|
||||||
|
elseif fields.enter then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, setchan, "enter")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
digistuff.button_turnoff = function (pos)
|
digistuff.button_turnoff = function (pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name=="digistuff:button_on" then --has not been dug
|
if node.name=="digistuff:button_on" then --has not been dug
|
||||||
@ -233,6 +280,40 @@ minetest.register_abm({
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("digistuff:panel", {
|
||||||
|
description = "Digilines Control Panel",
|
||||||
|
groups = {cracky=3},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local helpmsg = "Please set a channel."
|
||||||
|
digistuff.update_panel_formspec(pos,helpmsg)
|
||||||
|
end,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = {
|
||||||
|
"digistuff_panel_back.png",
|
||||||
|
"digistuff_panel_back.png",
|
||||||
|
"digistuff_panel_back.png",
|
||||||
|
"digistuff_panel_back.png",
|
||||||
|
"digistuff_panel_back.png",
|
||||||
|
"digistuff_panel_front.png"
|
||||||
|
},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{ -0.5, -0.5, 0.4, 0.5, 0.5, 0.5 }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
on_receive_fields = digistuff.panel_on_receive_fields,
|
||||||
|
digiline =
|
||||||
|
{
|
||||||
|
receptor = {},
|
||||||
|
effector = {
|
||||||
|
action = digistuff.panel_on_digiline_receive
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "digistuff:detector",
|
output = "digistuff:detector",
|
||||||
recipe = {
|
recipe = {
|
||||||
@ -241,3 +322,12 @@ minetest.register_craft({
|
|||||||
{"digilines:wire_std_00000000"}
|
{"digilines:wire_std_00000000"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "digistuff:panel",
|
||||||
|
recipe = {
|
||||||
|
{"","digistuff:button",""},
|
||||||
|
{"digistuff:button","digilines:lcd","digistuff:button"},
|
||||||
|
{"","digistuff:button",""}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
BIN
textures/digistuff_adwaita_edit-undo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/digistuff_adwaita_emblem-default.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
textures/digistuff_adwaita_go-down.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
textures/digistuff_adwaita_go-next.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
textures/digistuff_adwaita_go-previous.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/digistuff_adwaita_go-up.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/digistuff_panel_back.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
textures/digistuff_panel_bg.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
textures/digistuff_panel_front.png
Normal file
After Width: | Height: | Size: 9.7 KiB |