Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is ground content #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions ontime_clocks/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ minetest.register_node("ontime_clocks:green_digital", {
},
tiles = {"ontime_clocks_digital.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 13/32 - 0.01,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_digital_properties(
"#040", "#0F0", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down Expand Up @@ -74,14 +76,16 @@ minetest.register_node("ontime_clocks:red_digital", {
},
tiles = {"ontime_clocks_digital.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 13/32 - 0.01,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_digital_properties(
"#400", "#F00", ontime_clocks.get_h24(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down Expand Up @@ -112,14 +116,16 @@ minetest.register_node("ontime_clocks:white", {
},
tiles = {"ontime_clocks_white.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 6/16 - 0.01,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_needles_properties(
"#000", 36, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down Expand Up @@ -149,14 +155,16 @@ minetest.register_node("ontime_clocks:frameless_black", {
},
tiles = {"ontime_clocks_frameless.png"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_needles_properties(
"#000", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down Expand Up @@ -186,14 +194,16 @@ minetest.register_node("ontime_clocks:frameless_gold", {
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FF0"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_needles_properties(
"#FF0", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down Expand Up @@ -223,14 +233,16 @@ minetest.register_node("ontime_clocks:frameless_white", {
},
tiles = {"ontime_clocks_frameless.png^[colorize:#FFF"},
groups = {oddly_breakable_by_hand=1, not_blocking_trains=1, display_api=1},
is_ground_content = false,
display_entities = {
["ontime_clocks:display"] = {
depth = 7/16,
on_display_update = function(pos, objref)
objref:set_properties(
ontime_clocks.get_needles_properties(
"#FFF", 48, ontime_clocks.get_h12(), ontime_clocks.get_m12()))
end },
end
},
},
on_place = display_api.on_place,
on_construct = display_api.on_construct,
Expand Down
38 changes: 20 additions & 18 deletions signs_api/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,39 @@ function signs_api.register_sign(mod, name, model)
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-model.width/2, -model.height/2, 0.5,
model.width/2, model.height/2, 0.5 - model.depth},
fixed = {
-model.width/2, -model.height/2, 0.5,
model.width/2, model.height/2, 0.5 - model.depth
},
},
groups = {choppy=2, dig_immediate=2, not_blocking_trains=1, display_api=1},
is_ground_content = false,
sounds = default.node_sound_defaults(),
display_entities = {
["signs:display_text"] = {
on_display_update = font_api.on_display_update,
depth = 0.5 - display_api.entity_spacing - model.depth,
size = { x = model.width, y = model.height },
aspect_ratio = 1/2,
maxlines = 1,
on_display_update = font_api.on_display_update,
depth = 0.5 - display_api.entity_spacing - model.depth,
size = { x = model.width, y = model.height },
aspect_ratio = 1/2,
maxlines = 1,
},

},
on_place = display_api.on_place,
on_construct = function(pos)
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
local meta = minetest.get_meta(pos)
meta:set_string("font", ndef.display_entities.font_name or
font_api.get_default_font_name())
signs_api.set_formspec(pos)
display_api.on_construct(pos)
end,
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
local meta = minetest.get_meta(pos)
meta:set_string("font", ndef.display_entities.font_name or
font_api.get_default_font_name())
signs_api.set_formspec(pos)
display_api.on_construct(pos)
end,
on_destruct = display_api.on_destruct,
on_rotate = signs_api.on_rotate,
on_receive_fields = signs_api.on_receive_fields,
on_punch = function(pos, node, player, pointed_thing)
signs_api.set_formspec(pos)
display_api.update_entities(pos)
end,
signs_api.set_formspec(pos)
display_api.update_entities(pos)
end,
}

-- Node fields override
Expand Down
63 changes: 32 additions & 31 deletions steles/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,48 @@ for i, material in ipairs(steles.materials) do
},
},
groups = groups,
is_ground_content = false,
display_entities = {
["steles:text"] = {
on_display_update = font_api.on_display_update,
depth = -2/16 - display_api.entity_spacing,
top = -2/16,
aspect_ratio = 0.4,
size = { x = 10/16, y = 12/16 },
maxlines = 3,
on_display_update = font_api.on_display_update,
depth = -2/16 - display_api.entity_spacing,
top = -2/16,
aspect_ratio = 0.4,
size = { x = 10/16, y = 12/16 },
maxlines = 3,
},
},
on_place = function(itemstack, placer, pointed_thing)
minetest.rotate_node(itemstack, placer, pointed_thing)
return display_api.on_place(itemstack, placer, pointed_thing)
end,
minetest.rotate_node(itemstack, placer, pointed_thing)
return display_api.on_place(itemstack, placer, pointed_thing)
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", string.format([=[
size[6,4]%s%s%s
textarea[0.5,0.7;5.5,2;display_text;%s;${display_text}]
button[1,3;2,1;font;%s]
button_exit[3,3;2,1;ok;%s]]=],
default.gui_bg, default.gui_bg_img, default.gui_slots,
F("Displayed text (3 lines max)"),
F("Font"), F("Write")))
display_api.on_construct(pos)
end,
local meta = minetest.get_meta(pos)
meta:set_string("formspec", string.format([=[
size[6,4]%s%s%s
textarea[0.5,0.7;5.5,2;display_text;%s;${display_text}]
button[1,3;2,1;font;%s]
button_exit[3,3;2,1;ok;%s]]=],
default.gui_bg, default.gui_bg_img, default.gui_slots,
F("Displayed text (3 lines max)"),
F("Font"), F("Write")))
display_api.on_construct(pos)
end,
on_destruct = display_api.on_destruct,
on_rotate = display_api.on_rotate,
on_receive_fields = function(pos, formname, fields, player)
if not minetest.is_protected(pos, player:get_player_name()) then
local meta = minetest.get_meta(pos)
if fields.ok or fields.font then
meta:set_string("display_text", fields.display_text)
meta:set_string("infotext", "\""..fields.display_text.."\"")
display_api.update_entities(pos)
end
if fields.font then
font_api.show_font_list(player, pos)
end
if not minetest.is_protected(pos, player:get_player_name()) then
local meta = minetest.get_meta(pos)
if fields.ok or fields.font then
meta:set_string("display_text", fields.display_text)
meta:set_string("infotext", "\""..fields.display_text.."\"")
display_api.update_entities(pos)
end
if fields.font then
font_api.show_font_list(player, pos)
end
end,
end
end,
on_punch = display_api.update_entities,
})
end
Expand Down