mirror of
https://github.com/pyrollo/display_modpack.git
synced 2024-12-28 15:17:28 +01:00
Creation of steles mod
This commit is contained in:
parent
fa2be9fc8d
commit
a7e80f4b98
22
steles/README.md
Normal file
22
steles/README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Steles
|
||||
|
||||
This mod provides stone steles with text display. Text is locked if area is protected.
|
||||
|
||||
**Dependancies**: default, display\_lib, font\_lib, technic?
|
||||
|
||||
(Technic adds marble and granite steles)
|
||||
|
||||
**License**: WTFPL
|
||||
|
||||
## Recipes
|
||||
|
||||
- M -
|
||||
- B -
|
||||
M M M
|
||||
|
||||
B = Black Dye, M = Material
|
||||
|
||||
Material (must be all the same) can be : Stone, Desert Stone, Sandstone, Granite or Marble
|
||||
|
||||
Gives 4 steles of corresponding material. Right click on stele to update text.
|
||||
|
8
steles/config.lua
Normal file
8
steles/config.lua
Normal file
@ -0,0 +1,8 @@
|
||||
steles.materials = {
|
||||
'default:stone',
|
||||
'default:sandstone',
|
||||
'default:desert_stone',
|
||||
'technic:marble',
|
||||
'technic:granite',
|
||||
}
|
||||
|
13
steles/crafts.lua
Normal file
13
steles/crafts.lua
Normal file
@ -0,0 +1,13 @@
|
||||
for _, material in ipairs(steles.materials) do
|
||||
local parts = material:split(":")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'steles:'..parts[2]..'_stele 4',
|
||||
recipe = {
|
||||
{'', material, ''},
|
||||
{'', 'dye:black', ''},
|
||||
{material, material, material},
|
||||
}
|
||||
})
|
||||
|
||||
end
|
4
steles/depends.txt
Normal file
4
steles/depends.txt
Normal file
@ -0,0 +1,4 @@
|
||||
default
|
||||
display_lib
|
||||
font_lib
|
||||
technic?
|
14
steles/init.lua
Normal file
14
steles/init.lua
Normal file
@ -0,0 +1,14 @@
|
||||
-- Steles mod by P.Y. Rollo
|
||||
--
|
||||
-- License: WTFPL
|
||||
|
||||
steles = {}
|
||||
steles.path = minetest.get_modpath("steles")
|
||||
|
||||
dofile(steles.path.."/config.lua")
|
||||
dofile(steles.path.."/nodes.lua")
|
||||
dofile(steles.path.."/crafts.lua")
|
||||
|
||||
|
||||
|
||||
|
65
steles/nodes.lua
Normal file
65
steles/nodes.lua
Normal file
@ -0,0 +1,65 @@
|
||||
function steles.on_receive_fields(pos, formname, fields, player)
|
||||
if not minetest.is_protected(pos, player:get_player_name()) then
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields and fields.ok then
|
||||
meta:set_string("display_text", fields.display_text)
|
||||
meta:set_string("infotext", "\""..fields.display_text.."\"")
|
||||
display_lib.update_entities(pos)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
display_lib.register_display_entity("steles:text")
|
||||
|
||||
for _, material in ipairs(steles.materials) do
|
||||
|
||||
local ndef = minetest.registered_nodes[material]
|
||||
local parts = material:split(":")
|
||||
|
||||
minetest.register_node("steles:"..parts[2].."_stele", {
|
||||
description = ndef.description.." Stele",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
tiles = ndef.tiles,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-5/16, -4/16, -2/16, 5/16, 0.5, 2/16},
|
||||
{-7/16, -0.5, -4/16, 7/16, -4/16, 4/16}
|
||||
}
|
||||
},
|
||||
groups = ndef.groups,
|
||||
display_entities = {
|
||||
["steles:text"] = {
|
||||
on_display_update = font_lib.on_display_update,
|
||||
depth = -2/16-0.001, height = 2/16,
|
||||
size = { x = 14/16, y = 12/16 },
|
||||
resolution = { x = 144, y = 64 },
|
||||
maxlines = 3,
|
||||
},
|
||||
},
|
||||
on_place = display_lib.on_place,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", "size[6,4]"..
|
||||
"textarea[0.5,0.7;5.5,2;display_text;Displayed text (3 lines max);${display_text}]"..
|
||||
"button_exit[2,3;2,1;ok;Write]")
|
||||
display_lib.on_construct(pos)
|
||||
end,
|
||||
on_destruct = display_lib.on_destruct,
|
||||
on_rotate = display_lib.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 and fields.ok then
|
||||
meta:set_string("display_text", fields.display_text)
|
||||
meta:set_string("infotext", "\""..fields.display_text.."\"")
|
||||
display_lib.update_entities(pos)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user