Add mods: digiprinter, digiboard, digilines_weather_sensor, digilines_memory, digilines_crafting, homedecor_plastic

This commit is contained in:
jogag 2015-08-26 17:21:57 +02:00
commit 0a14ab26c1
25 changed files with 525 additions and 0 deletions

2
digiboard/depends.txt Normal file

@ -0,0 +1,2 @@
default
digilines

53
digiboard/init.lua Normal file

@ -0,0 +1,53 @@
-- Original Digiboard mod by bas080
-- Cracked by jogag
-- Added features: settable channel, no more minetest.env, settable field caption (via digiline)
minetest.register_node("digiboard:keyboard", {
description = "Digiboard",
tiles = {"keyboard_top.png", "keyboard_bottom.png", "keyboard_side.png", "keyboard_side.png", "keyboard_side.png", "keyboard_side.png"},
walkable = true,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-4/8, -4/8, 0, 4/8, -3/8, 4/8},
},
},
selection_box = {
type = "fixed",
fixed = {
{-4/8, -4/8, 0, 4/8, -3/8, 4/8},
},
},
digiline = { receptor = {},
effector = {
action = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
if channel == meta:get_string("channel") then
meta:set_string("formspec", "field[text;"..msg..";]")
end
end
},
},
groups = {choppy = 3, dig_immediate = 2},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;Channel;]")
meta:set_string("infotext", "Keyboard")
meta:set_int("lines", 0)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local channel = meta:get_string("channel")
if fields.channel then
meta:set_string("channel")
meta:set_string("formspec", "field[text;Enter text;]")
elseif fields.text then
digiline:receptor_send(pos, digiline.rules.default, channel, text)
end
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

@ -0,0 +1,64 @@
-- Created by jogag
-- Part of the Digiline Stuff pack
-- Mod: crafting recipes for all devices
-- Also adds recipes for RTC and Lightsensor
------------------------------
-- DIGILINE BUILTIN DEVICES --
------------------------------
-- RTC
minetest.register_craft({
output = "digilines_rtc:rtc 2",
recipe = {
{ "default:steel_ingot" },
{ "mesecons_materials:silicon" },
{ "digilines:wire_std_00000000" },
},
})
-- Light sensor
minetest.register_craft({
output = "digilines_lightsensor:lightsensor 2",
recipe = {
{ "homedecor:plastic", "default:glass" },
{ "", "mesecons_materials:silicon" },
{ "", "digilines:wire_std_00000000" },
},
})
-------------------------
-- DIGILINE STUFF PACK --
-------------------------
-- Memory chip (16 spaces)
minetest.register_craft({
output = "digilines_memory:memory_1",
recipe = {
{ "mesecons_materials:silicon", "mesecons_materials:silicon", "mesecons_materials:silicon" },
{ "group:mesecon_conductor_craftable", "default:mese_crystal_fragment", "group:mesecon_conductor_craftable" },
{ "mesecons_materials:fiber", "digilines:wire_std_00000000", "mesecons_materials:fiber" },
},
})
-- Weather sensor
minetest.register_craft({
output = "digilines_weather_sensor:sensor 2",
recipe = {
{ "default:stick" },
{ "mesecons_materials:silicon" },
{ "digilines:wire_std_00000000" },
},
})
-- Digiprinter
minetest.register_craft({
output = "digiprinter:printer",
recipe = {
{ "homedecor:plastic_sheeting", "", "" },
{ "digilines:wire_std_00000000", "default:mese_crystal", "homedecor:plastic_sheeting" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
},
})

@ -0,0 +1 @@
digilines

104
digilines_memory/init.lua Normal file

@ -0,0 +1,104 @@
-- Created by jogag
-- Part of the Digiline Stuff pack
-- Mod: digiline memory chip
-- A memory chip you can use to store several strings
-- "SET <address> <string>" to write
-- "GET <address>" to read
-- "ERASE" to delete all!!! xD
local GET_CMD = "GET"
local SET_CMD = "SET"
local DEL_CMD = "ERASE"
local OK_MSG = "OK"
-- list with the various chip sizes
-- (put two equal chips in crafting grid to upgrade)
local MEMORY_CHIPS = { 16, 32, 64, 128, 256, 512, 1024 }
-- all taken from digiline RTC mod
local chip_nodebox =
{
type = "fixed",
fixed = {
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- bottom slab
{ -7/16, -7/16, -7/16, 7/16, -5/16, 7/16 },
}
}
local chip_selbox =
{
type = "fixed",
fixed = {{ -8/16, -8/16, -8/16, 8/16, -3/16, 8/16 }}
}
local get_chip_size = function(pos)
return MEMORY_CHIPS[tonumber(minetest.get_node(pos).name:split("_")[3])]
end
local on_digiline_receive = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
local data = minetest.deserialize(meta:get_string("data"))
-- ^^ xDDDDD
if channel == meta:get_string("channel") then
if msg == DEL_CMD then
meta:set_string("data", "return {}")
digiline:receptor_send(pos, digilines.rules.default, channel, OK_MSG)
return
end
if msg:split(" ")[2] == nil then return end -- no arguments :/
cmd = msg:split(" ")[2]
addr = tonumber(msg:split(" ")[2])
if addr == nil or addr < 1 or addr > get_chip_size(pos) then return end -- invalid address
if cmd == GET_CMD then digiline:receptor_send(pos, digiline.rules.default, channel, data[addr])
elseif cmd == SET_CMD and msg:split(" ")[3] ~= nil then
data[addr] = msg:sub(cmd:len() + tostring(addr):len() + 2, -1) -- its too complicated...
meta:set_string("data", minetest.serialize(data))
digiline:receptor_send(pos, digilines.rules.default, channel, OK_MSG)
end
end
end
for i, s in ipairs(MEMORY_CHIPS) do
minetest.register_node("digilines_memory:memory_"..i, {
description = "Digiline Memory Chip ("..s.." addresses)",
drawtype = "nodebox",
tiles = {"digilines_memory.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {dig_immediate=2},
selection_box = chip_selbox,
node_box = chip_nodebox,
digiline = {
receptor = {},
effector = { action = on_digiline_receive },
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;Channel;${channel}]")
meta:set_string("infotext", "Memory Chip ("..get_chip_size(pos).." addresses)")
meta:set_string("channel", "")
meta:set_string("data", "return {}") -- xD
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.channel then minetest.get_meta(pos):set_string("channel", fields.channel) end
end,
})
if i ~= 1 then
minetest.register_craft({
type = "shapeless",
output = "digilines_memory:memory_"..i,
recipe = {
"digilines_memory:memory_"..(i - 1),
"digilines_memory:memory_"..(i - 1),
},
})
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 B

@ -0,0 +1,2 @@
digilines
weather

@ -0,0 +1,64 @@
-- Created by jogag
-- Part of the Digiline Stuff pack
-- Mod: digiline rain sensor
-- Compatible with Weather mod and my own Weather+ mod
-- Send "GET" to obtain the current weather (none, rain, snow, error)
-- If you get "error" is because the weather mod is not installed
local GET_CMD = "GET"
local ERR_MSG = "none"
-- all taken from digiline lightsensor mod
local wsensor_nodebox =
{
type = "fixed",
fixed = {
{ -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }, -- bottom slab
{ -7/16, -7/16, -7/16, -4/16, -5/16, 7/16 }, -- bonds
{ 4/16, -7/16, -7/16, 7/16, -5/16, 7/16 },
{ -7/16, -7/16, -7/16, 7/16, -5/16, -4/16 },
{ -7/16, -7/16, 4/16, 7/16, -5/16, 7/16 },
{ -1/16, -7/16, -1/16, 1/16, -5/16, 1/16 }, -- pin thing in the middle
}
}
local wsensor_selbox =
{
type = "fixed",
fixed = {{ -8/16, -8/16, -8/16, 8/16, -3/16, 8/16 }}
}
local on_digiline_receive = function (pos, node, channel, msg)
local setchan = minetest.get_meta(pos):get_string("channel")
if channel == setchan and msg == GET_CMD then
local value = weather and tostring(weather) or ERR_MSG
digiline:receptor_send(pos, digiline.rules.default, channel, value)
end
end
minetest.register_node("digilines_weather_sensor:sensor", {
description = "Digiline Rain Sensor",
drawtype = "nodebox",
tiles = {"digilines_weather_sensor.png"},
paramtype = "light",
groups = {dig_immediate=2},
selection_box = wsensor_selbox,
node_box = wsensor_nodebox,
digiline = {
receptor = {},
effector = { action = on_digiline_receive },
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;Channel;${channel}]")
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.channel then minetest.get_meta(pos):set_string("channel", fields.channel) end
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

2
digiprinter/depends.txt Normal file

@ -0,0 +1,2 @@
digilines
memorandum

154
digiprinter/init.lua Normal file

@ -0,0 +1,154 @@
-- Created by jogag
-- Part of the Digiline Stuff pack
-- Mod: Digiprinter - a digiline-controlled printer
-- It prints paper via the Writable Paper (memorandum) mod
-- then it sends "OK" or "ERR_PAPER" or "ERR_SPACE"
local OK_MSG = "OK"
local NO_PAPER_MSG = "ERR_PAPER"
local NO_SPACE_MSG = "ERR_SPACE"
local PRINT_DELAY = 3
-- taken from pipeworks mod
local function facedir_to_dir(facedir)
--a table of possible dirs
return ({{x=0, y=0, z=1},
{x=1, y=0, z=0},
{x=0, y=0, z=-1},
{x=-1, y=0, z=0},
{x=0, y=-1, z=0},
{x=0, y=1, z=0}})
--indexed into by a table of correlating facedirs
[({[0]=1, 2, 3, 4,
5, 2, 6, 4,
6, 2, 5, 4,
1, 5, 3, 6,
1, 6, 3, 5,
1, 4, 3, 2})
--indexed into by the facedir in question
[facedir]]
end
local print_paper = function(pos, node, msg)
local inv = minetest.get_meta(pos):get_inventory()
local vel = facedir_to_dir(node.param2)
local front = { x = pos.x - vel.x, y = pos.y - vel.y, z = pos.z - vel.z }
if minetest.get_node(front).name ~= "air" then
-- search for the next block
vel = { x = vel.x * 2, y = vel.y * 2, z = vel.z * 2 }
front = { x = pos.x - vel.x, y = pos.y - vel.y, z = pos.z - vel.z }
end
if inv:is_empty("paper") then digiline:receptor_send(pos, digiline.rules.default, channel, NO_PAPER_MSG)
elseif minetest.get_node(front).name ~= "air" then digiline:receptor_send(pos, digiline.rules.default, channel, NO_SPACE_MSG)
else
local paper = inv:get_stack("paper", 1)
paper:take_item()
inv:set_stack("paper", 1, paper)
minetest.add_node(front, {
name = (msg == "" and "memorandum:letter_empty" or "memorandum:letter_written"),
param2 = node.param2
})
local meta = minetest.get_meta(front)
meta:set_string("text", msg)
meta:set_string("signed", "Digiprinter")
meta:set_string("infotext", 'On this piece of paper is written: "'..msg..'" Printed with Digiprinter') -- xD
digiline:receptor_send(pos, digiline.rules.default, channel, OK_MSG)
end
minetest.get_meta(pos):set_string("infotext", "Digiline Printer Idle")
end
local on_digiline_receive = function(pos, node, channel, msg)
local meta = minetest.get_meta(pos)
if channel == meta:get_string("channel") and not meta:get_string("infotext"):find("Busy") then
meta:set_string("infotext", "Digiline Printer Busy")
minetest.after(PRINT_DELAY, print_paper, pos, node, msg)
end
end
-- taken from computer mod xD
minetest.register_node("digiprinter:printer", {
description = "Digiline Printer",
inventory_image = "computer_printer_inv.png",
tiles = {"digiprinter_t.png","digiprinter_bt.png","digiprinter_l.png",
"digiprinter_r.png","digiprinter_b.png","digiprinter_f.png"},
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
groups = {snappy=3},
sound = default.node_sound_wood_defaults(),
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.4375, -0.3125, -0.125, 0.4375, -0.0625, 0.375},
{-0.4375, -0.5, -0.125, 0.4375, -0.4375, 0.375},
{-0.4375, -0.5, -0.125, -0.25, -0.0625, 0.375},
{0.25, -0.5, -0.125, 0.4375, -0.0625, 0.375},
{-0.4375, -0.5, -0.0625, 0.4375, -0.0625, 0.375},
{-0.375, -0.4375, 0.25, 0.375, -0.0625, 0.4375},
{-0.25, -0.25, 0.4375, 0.25, 0.0625, 0.5},
{-0.25, -0.481132, -0.3125, 0.25, -0.4375, 0}
},
},
digiline = {
receptor = {},
effector = {
action = on_digiline_receive
},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("channel", "")
meta:set_string("infotext", "Digiline Printer Idle")
meta:set_string("formspec", "size[8,10]"..
((default and default.gui_bg) or "")..
((default and default.gui_bg_img) or "")..
((default and default.gui_slots) or "")..
"label[0,0;Digiline Printer]"..
"label[3.5,2;Paper]"..
"list[current_name;paper;3.5,2.5;1,1;]"..
"field[2,3.5;5,5;channel;Channel;${channel}]"..
((default and default.get_hotbar_bg) and default.get_hotbar_bg(0,6) or "")..
"list[current_player;main;0,6;8,4;]")
local inv = meta:get_inventory()
inv:set_size("paper", 1)
end,
on_receive_fields = function(pos, formname, fields, sender)
if fields.channel then minetest.get_meta(pos):set_string("channel", fields.channel) end
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then return 0 end
return (stack:get_name() == "default:paper" and stack:get_count() or 0)
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
return (minetest.get_meta(pos):get_string("infotext"):find("Busy") and stack:get_count() or 0)
end,
can_dig = function(pos, player)
return minetest.get_meta(pos):get_inventory():is_empty("paper")
end,
})
-- printer crafting:
-- +-------+
-- | ? P ? |
-- | ? M ? |
-- | ? D ? |
-- +-------+
minetest.register_craft({
output = "digiprinter:printer",
recipe = {
{ "homedecor", "default:paper", "" },
{ "", "default:mese_crystal", "" },
{ "", "digilines:wire_std_000000", "" },
},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

@ -0,0 +1,79 @@
-- Created by jogag
-- Part of the Digiline Stuff pack
-- Mod: Plastic from homedecor, if homedecor is not installed :)
-- + Also checks for pipeworks!
-- Texture license: from VanessaE, WTFPL
if not minetest.get_modpath("homedecor") and not minetest.get_modpath("pipeworks") then
minetest.register_craftitem(":homedecor:oil_extract", {
description = "Oil extract",
inventory_image = "homedecor_oil_extract.png",
})
minetest.register_craftitem(":homedecor:paraffin", {
description = "Unprocessed paraffin",
inventory_image = "homedecor_paraffin.png",
})
minetest.register_alias("homedecor:plastic_base", "homedecor:paraffin")
minetest.register_craftitem(":homedecor:plastic_sheeting", {
description = "Plastic sheet",
inventory_image = "homedecor_plastic_sheeting.png",
})
minetest.register_craft({
type = "shapeless",
output = "homedecor:oil_extract 6",
recipe = { "default:junglegrass",
"default:junglegrass",
"default:junglegrass"
}
})
minetest.register_craft({
type = "shapeless",
output = "homedecor:oil_extract 3",
recipe = { "default:dry_shrub",
"default:dry_shrub",
"default:dry_shrub"
},
})
minetest.register_craft({
type = "shapeless",
output = "homedecor:oil_extract 4",
recipe = { "default:leaves",
"default:leaves",
"default:leaves",
"default:leaves",
"default:leaves",
"default:leaves"
}
})
minetest.register_craft({
type = "cooking",
output = "homedecor:paraffin",
recipe = "homedecor:oil_extract",
})
minetest.register_craft({
type = "fuel",
recipe = "homedecor:paraffin",
burntime = 30,
})
minetest.register_craft({
type = "fuel",
recipe = "homedecor:plastic_sheeting",
burntime = 30,
})
minetest.register_alias("pipeworks:oil_extract", "homedecor:oil_extract")
minetest.register_alias("pipeworks:paraffin", "homedecor:paraffin")
minetest.register_alias("pipeworks:plastic_sheeting", "homedecor:plastic_sheeting")
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B