This commit is contained in:
Pierre-Yves Rollo 2018-12-09 19:49:22 +01:00
commit c28da681bf
13 changed files with 784 additions and 151 deletions

78
crafts.lua Normal file
View File

@ -0,0 +1,78 @@
--[[
digiterms mod for Minetest - Digilines monitors using Display API / Font API
(c) Pierre-Yves Rollo
This file is part of digiterms.
signs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
signs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with signs. If not, see <http://www.gnu.org/licenses/>.
--]]
local function material_fallback(list)
for _, material in ipairs(list) do
if minetest.registered_items[material] then
return material
end
end
end
local body = material_fallback({
'homedecor:plastic_sheeting',
'default:steel_ingot',
})
local glass = material_fallback({
'xpanes:pane_flat',
'default:glass',
})
local electronic = material_fallback({
'mesecons_microcontroller:microcontroller0000',
'mesecons_luacontroller:luacontroller0000',
'default:copper_ingot',
})
local wire = 'digilines:wire_std_00000000'
print("Craft materials:")
print("Body: "..(body or "None!"))
print("Glass: "..(glass or "None!"))
print("Electronic: "..(electronic or "None!"))
print("Wire: "..(wire or "None!"))
minetest.register_craft({
output = "digiterms:lcd_monitor 1",
recipe = {
{body, electronic, ''},
{glass, material_fallback({'mesecons_materials:silicon', 'dye:black'}), ''},
{body, wire, ''}
}
})
minetest.register_craft({
output = "digiterms:cathodic_amber_monitor",
recipe = {
{body, body, ''},
{glass, 'dye:orange', electronic},
{body, body, wire}
}
})
minetest.register_craft({
output = "digiterms:cathodic_green_monitor 1",
recipe = {
{body, body, ''},
{glass, 'dye:green', electronic},
{body, body, wire}
}
})

View File

@ -1,3 +1,12 @@
display_api
font_api
digilines
dye
default
xpane?
scifi_nodes?
basic_materials?
homedecor?
mesecons_microcontroller?
mesecons_luacontroller?
mesecons_materials?

View File

@ -18,8 +18,6 @@
along with signs. If not, see <http://www.gnu.org/licenses/>.
--]]
digiterms.columns = 30
local function get_lines(pos)
local lines = {}
local meta = minetest.get_meta(pos)
@ -74,8 +72,96 @@ local function push_text(lines, text, maxlines, maxcolumns)
end
function digiterms.push_text_on_screen(pos, text)
local lines = get_lines(pos)
push_text(lines, text, 6, digiterms.columns)
set_lines(pos, lines)
display_api.update_entities(pos)
local def = minetest.registered_nodes[minetest.get_node(pos).name]
if def.display_entities and def.display_entities["digiterms:screen"] then
def = def.display_entities["digiterms:screen"]
if def.lines and def.columns then
local lines = get_lines(pos)
push_text(lines, text, def.lines, def.columns)
set_lines(pos, lines)
display_api.update_entities(pos)
else
minetest.log("warning", "[digiterms] At "..minetest.pos_to_string(pos)
..", digiterms:screen entity should have 'lines' and 'columns' attribures.")
end
else
minetest.log("warning", "[digiterms] Node at "..minetest.pos_to_string(pos)
.." does not have digiterms:screen entity.")
end
end
local node_def_defaults = {
groups = { display_api = 1},
on_place = display_api.on_place,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
on_punch = display_api.update_entities,
on_construct = function(pos)
minetest.get_meta(pos):set_string("formspec",
"field[channel;Channel;${channel}]")
display_api.on_construct(pos)
end,
on_receive_fields = function(pos, formname, fields, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
if (fields.channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
end,
digiline = {
wire = { use_autoconnect = false },
receptor = {},
effector = {
action = function(pos, _, channel, msg)
if channel ~= minetest.get_meta(pos):get_string("channel") then
return
end
digiterms.push_text_on_screen(pos, msg)
end,
},
},
}
function superpose_table(base, exceptions)
local result = table.copy(base)
for key, value in pairs(exceptions) do
if type(value) == 'table' then
result[key] = superpose_table(result[key] or {}, value)
else
result[key] = value
end
end
return result
end
function digiterms.register_monitor(
nodename, nodedef, nodedefon, nodedefoff)
local ndef = superpose_table(node_def_defaults, nodedef)
if nodedefon and nodedefoff then
ndef.on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = nodename..'_off',
param = node.param, param2 = node.param2 })
end
minetest.register_node(nodename, superpose_table(ndef, nodedefon))
-- Register the corresponding Off node
ndef.drops = nodename
ndef.groups.not_in_creative_inventory = 1
ndef.on_destruct = nil
ndef.on_punch = function(pos, node)
minetest.swap_node(pos, {name = nodename, -- Stange but it works
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end
minetest.register_node(nodename..'_off', superpose_table(ndef, nodedefoff))
else
minetest.register_node(nodename, ndef)
end
end

View File

@ -23,9 +23,15 @@ digiterms.name = minetest.get_current_modname()
digiterms.path = minetest.get_modpath(digiterms.name)
digiterms.font = "mozart"
display_api.register_display_entity("digiterms:screen")
dofile(digiterms.path.."/font_mozart.lua")
dofile(digiterms.path.."/functions.lua")
dofile(digiterms.path.."/nodes.lua")
--dofile(digiterms.path.."/crafts.lua")
dofile(digiterms.path.."/crafts.lua")
display_api.register_display_entity("digiterms:screen")
if minetest.get_modpath("scifi_nodes") then
print ('[digiterms] scifi_nodes mod present, adding some more nodes')
dofile(digiterms.path.."/scifi_nodes.lua")
dofile(digiterms.path.."/scifi_crafts.lua")
end

160
nodes.lua
View File

@ -18,57 +18,6 @@
along with signs. If not, see <http://www.gnu.org/licenses/>.
--]]
local common_node_def = {
groups = { display_api = 1},
on_place = display_api.on_place,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
on_punch = display_api.update_entities,
on_construct = function(pos)
minetest.get_meta(pos):set_string("formspec",
"field[channel;Channel;${channel}]")
display_api.on_construct(pos)
end,
on_receive_fields = function(pos, formname, fields, player)
local name = player:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return
end
if (fields.channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
end,
digiline = {
wire = { use_autoconnect = false },
receptor = {},
effector = {
action = function(pos, _, channel, msg)
if channel ~= minetest.get_meta(pos):get_string("channel") then
return
end
digiterms.push_text_on_screen(pos, msg)
end,
},
},
}
function digiterms.register_monitor(nodename, nodedef)
def = table.copy(common_node_def)
for key, value in pairs(nodedef) do
if key == 'groups' then
def[key] = def[key] or {}
for key2, value2 in pairs(value) do
def[key][key2] = value2
end
else
def[key] = value
end
end
minetest.register_node(nodename, def)
end
local cathodic_node_box = {
type = "fixed",
fixed = {
@ -111,9 +60,6 @@ digiterms.register_monitor('digiterms:lcd_monitor', {
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = false,
tiles = { "digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_back.png", "digiterms_lcd_front.png" },
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1},
node_box = lcd_node_box,
@ -129,36 +75,14 @@ digiterms.register_monitor('digiterms:lcd_monitor', {
color = "#203020", font_name = digiterms.font, halign="left", valing="top",
},
},
on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = 'digiterms:lcd_monitor_off',
param = node.param, param2 = node.param2 })
end
})
minetest.register_node('digiterms:lcd_monitor_off', {
description = "LCD monitor",
paramtype = "light",
paramtype2 = "facedir",
drops = "digiterms:lcd_monitor",
sunlight_propagates = false,
}, {
tiles = { "digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_back.png", "digiterms_lcd_front.png" },
}, {
tiles = { "digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_sides.png", "digiterms_lcd_sides.png",
"digiterms_lcd_back.png", "digiterms_lcd_front_off.png" },
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory = 1},
node_box = lcd_node_box,
collision_box = lcd_collision_box,
selection_box = lcd_collision_box,
on_place = display_api.on_place,
on_receive_fields = common_node_def.on_receive_fields,
on_punch = function(pos, node)
minetest.swap_node(pos, {name = 'digiterms:lcd_monitor',
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end,
})
digiterms.register_monitor('digiterms:cathodic_amber_monitor', {
@ -166,9 +90,6 @@ digiterms.register_monitor('digiterms:cathodic_amber_monitor', {
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = false,
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
"digiterms_amber_sides.png", "digiterms_amber_sides.png^[transformFX]",
"digiterms_amber_back.png", "digiterms_amber_front.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1},
node_box = cathodic_node_box,
@ -184,36 +105,14 @@ digiterms.register_monitor('digiterms:cathodic_amber_monitor', {
color = "#FFA000", font_name = digiterms.font, halign="left", valing="top",
},
},
on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = 'digiterms:cathodic_amber_monitor_off',
param = node.param, param2 = node.param2 })
end
})
minetest.register_node('digiterms:cathodic_amber_monitor_off', {
description = "Cathodic amber monitor",
paramtype = "light",
paramtype2 = "facedir",
drops = "digiterms:cathodic_amber_monitor",
sunlight_propagates = false,
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
}, {
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
"digiterms_amber_sides.png", "digiterms_amber_sides.png^[transformFX]",
"digiterms_amber_back.png", "digiterms_amber_front_off.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory = 1},
node_box = cathodic_node_box,
collision_box = cathodic_collision_box,
selection_box = cathodic_collision_box,
on_place = display_api.on_place,
on_receive_fields = common_node_def.on_receive_fields,
on_punch = function(pos, node)
minetest.swap_node(pos, {name = 'digiterms:cathodic_amber_monitor',
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end,
"digiterms_amber_back.png", "digiterms_amber_front.png",},
}, {
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
"digiterms_amber_sides.png", "digiterms_amber_sides.png^[transformFX]",
"digiterms_amber_back.png", "digiterms_amber_front_off.png",},
})
digiterms.register_monitor('digiterms:cathodic_green_monitor', {
@ -221,9 +120,6 @@ digiterms.register_monitor('digiterms:cathodic_green_monitor', {
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = false,
tiles = { "digiterms_green_top.png", "digiterms_green_bottom.png",
"digiterms_green_sides.png", "digiterms_green_sides.png^[transformFX]",
"digiterms_green_back.png", "digiterms_green_front.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1},
node_box = cathodic_node_box,
@ -239,34 +135,12 @@ digiterms.register_monitor('digiterms:cathodic_green_monitor', {
color = "#00FF00", font_name = digiterms.font, halign="left", valing="top",
},
},
on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = 'digiterms:cathodic_green_monitor_off',
param = node.param, param2 = node.param2 })
end
})
minetest.register_node('digiterms:cathodic_green_monitor_off', {
description = "Cathodic green monitor",
paramtype = "light",
paramtype2 = "facedir",
drops = "digiterms:cathodic_green_monitor",
sunlight_propagates = false,
}, {
tiles = { "digiterms_green_top.png", "digiterms_green_bottom.png",
"digiterms_green_sides.png", "digiterms_green_sides.png^[transformFX]",
"digiterms_green_back.png", "digiterms_green_front.png",},
}, {
tiles = { "digiterms_green_top.png", "digiterms_green_bottom.png",
"digiterms_green_sides.png", "digiterms_green_sides.png^[transformFX]",
"digiterms_green_back.png", "digiterms_green_front_off.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory = 1},
node_box = cathodic_node_box,
collision_box = cathodic_collision_box,
selection_box = cathodic_collision_box,
on_place = display_api.on_place,
on_receive_fields = common_node_def.on_receive_fields,
on_punch = function(pos, node)
minetest.swap_node(pos, {name = 'digiterms:cathodic_green_monitor',
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end,
})

45
scifi_crafts.lua Normal file
View File

@ -0,0 +1,45 @@
--[[
digiterms mod for Minetest - Digilines monitors using Display API / Font API
(c) Pierre-Yves Rollo
This file is part of digiterms.
signs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
signs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with signs. If not, see <http://www.gnu.org/licenses/>.
--]]
local wire = 'digilines:wire_std_00000000'
minetest.register_craft({
output = "digiterms:scifi_glassscreen",
type = "shapeless",
recipe = { "scifi_nodes:glassscreen", "digilines:wire_std_00000000" }
})
minetest.register_craft({
output = "digiterms:scifi_widescreen",
type = "shapeless",
recipe = { "scifi_nodes:widescreen", "digilines:wire_std_00000000" }
})
minetest.register_craft({
output = "digiterms:scifi_tallscreen",
type = "shapeless",
recipe = { "scifi_nodes:tallscreen", "digilines:wire_std_00000000" }
})
minetest.register_craft({
output = "digiterms:scifi_keysmonitor",
type = "shapeless",
recipe = { "scifi_nodes:keysmonitor", "digilines:wire_std_00000000" }
})

169
scifi_nodes.lua Normal file
View File

@ -0,0 +1,169 @@
--[[
font_api mod for Minetest - Library to add font display capability
to display_api mod.
(c) Pierre-Yves Rollo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
digiterms.register_monitor("digiterms:scifi_glassscreen", {
description = "Digiline glassscreen",
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = true,
sunlight_propagates = true,
light_source = 15,
tiles = {
"digiterms_scifi_glscrn.png",
"digiterms_scifi_glscrn.png",
"digiterms_scifi_glscrn.png",
"digiterms_scifi_glscrn.png",
"digiterms_scifi_glscrn.png",
"digiterms_scifi_glscrn.png",
},
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.4375, -0.5, -0.125, 0.4375, -0.1875, 0.0625}, -- NodeBox1
{-0.375, -0.5, -0.0625, 0.375, 0.5, 0}, -- NodeBox10
}
},
sounds = default.node_sound_glass_defaults(),
groups = {choppy = 1, oddly_breakable_by_hand = 1},
display_entities = {
["digiterms:screen"] = {
on_display_update = font_api.on_display_update,
depth = -1/32,
top = -5/32,
size = { x = 23/32, y = 10/16 },
columns = 20, lines = 4,
color = "#76EDCD", font_name = digiterms.font, halign="left", valing="top",
},
},
})
digiterms.register_monitor("digiterms:scifi_widescreen", {
description = "Digiline widescreen",
tiles = {
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"digiterms_scifi_widescreen.png"
},
drawtype = "nodebox",
paramtype = "light",
light_source = 5,
paramtype2 = "facedir",
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.3125, 0.4375, 0.375, 0.3125, 0.5}, -- NodeBox1
{-0.5, -0.375, 0.375, -0.375, 0.375, 0.5}, -- NodeBox2
{0.375, -0.375, 0.375, 0.5, 0.375, 0.5}, -- NodeBox3
{-0.3125, 0.25, 0.375, 0.3125, 0.375, 0.5}, -- NodeBox4
{-0.3125, -0.375, 0.375, 0.25, -0.25, 0.5}, -- NodeBox5
{-0.5, -0.3125, 0.375, 0.5, -0.25, 0.5}, -- NodeBox6
{-0.5, 0.25, 0.375, 0.5, 0.3125, 0.5}, -- NodeBox7
}
},
groups = {cracky=1, oddly_breakable_by_hand=1},
display_entities = {
["digiterms:screen"] = {
on_display_update = font_api.on_display_update,
depth = 7/16 - display_api.entity_spacing,
size = { x = 11/16, y = 8/16 },
columns = 12, lines = 2,
color = "#72ba9a", font_name = digiterms.font, halign="left", valing="top",
},
},
})
digiterms.register_monitor("digiterms:scifi_tallscreen", {
description = "Digiline tallscreen",
tiles = {
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"digiterms_scifi_tallscreen.png"
},
drawtype = "nodebox",
light_source = 5,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.375, 0.4375, 0.3125, 0.375, 0.5}, -- NodeBox1
{-0.375, 0.375, 0.375, 0.375, 0.5, 0.5}, -- NodeBox2
{-0.375, -0.5, 0.375, 0.375, -0.375, 0.5}, -- NodeBox3
{0.25, -0.3125, 0.375, 0.375, 0.3125, 0.5}, -- NodeBox4
{-0.375, -0.25, 0.375, -0.25, 0.3125, 0.5}, -- NodeBox5
{-0.3125, -0.5, 0.375, -0.25, 0.5, 0.5}, -- NodeBox6
{0.25, -0.5, 0.375, 0.3125, 0.5, 0.5}, -- NodeBox7
}
},
groups = {cracky=1, oddly_breakable_by_hand=1},
display_entities = {
["digiterms:screen"] = {
on_display_update = font_api.on_display_update,
depth = 7/16 - display_api.entity_spacing,
size = { x = 7/16, y = 12/16 },
columns = 8, lines = 3,
color = "#72ba9a", font_name = digiterms.font, halign="left", valing="top",
},
},
})
digiterms.register_monitor("digiterms:scifi_keysmonitor", {
description = "Digiline keyboard and monitor",
tiles = {
"scifi_nodes_keyboard.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"scifi_nodes_black.png",
"digiterms_scifi_monitor.png"
},
drawtype = "nodebox",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.4375, 0.5, -0.4375, -0.0625}, -- NodeBox1
{-0.125, -0.5, 0.375, 0.125, 0.0625, 0.4375}, -- NodeBox2
{-0.25, -0.5, 0.125, 0.25, -0.4375, 0.5}, -- NodeBox3
{-0.5, -0.3125, 0.25, 0.5, 0.5, 0.375}, -- NodeBox4
}
},
groups = {cracky=1, oddly_breakable_by_hand=1},
display_entities = {
["digiterms:screen"] = {
on_display_update = font_api.on_display_update,
depth = 4/16 - display_api.entity_spacing,
top = -5/32,
size = { x = 10/16, y = 7/16 },
columns = 16, lines = 3,
color = "#B4F1EC", font_name = digiterms.font, halign="left", valing="top",
},
},
})

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

366
svg/scifi_monitors.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB