2 --Code and Textures are under the CC by-sa 3.0 licence
3 --see: http://creativecommons.org/licenses/by-sa/3.0/
7 if (minetest
.get_modpath("intllib")) then
8 dofile(minetest
.get_modpath("intllib").."/intllib.lua")
9 S
= intllib
.Getter(minetest
.get_current_modname())
11 S
= function ( s
) return s
end
16 function arrow_signs
:savetext(pos
, formname
, fields
, sender
)
18 if not minetest
.get_player_privs(sender
:get_player_name())["interact"] then
19 minetest
.chat_send_player(sender
:get_player_name(), "error: you don't have permission to edit the sign. you need the interact priv")
22 local meta
= minetest
.env
:get_meta(pos
)
23 fields
.text
= fields
.text
or ""
24 print((sender
:get_player_name() or "").." wrote \""..fields
.text
..
25 "\" to sign at "..minetest
.pos_to_string(pos
))
26 meta
:set_string("text", fields
.text
)
27 text
= arrow_signs
:create_lines(fields
.text
)
28 meta
:set_string("infotext", text
)
30 for wort
in text
:gfind("\n") do
34 minetest
.chat_send_player(sender
:get_player_name(),"\tInformation: \nYou've written more than 5 lines. \n it may be that not all lines are displayed. \n Please remove the last entry")
39 function arrow_signs
:create_lines(text
)
40 text
= text
:gsub("/", "\"\n\"")
41 text
= text
:gsub("|", "\"\n\"")
46 local clone_registered
= function(case
,name
)
49 if case
== "item" then list
= minetest
.registered_items
end
50 if case
== "node" then list
= minetest
.registered_nodes
end
51 if case
== "craftitem" then list
= minetest
.registered_craftitems
end
52 if case
== "tool" then list
= minetest
.registered_tools
end
53 if case
== "entity" then list
= minetest
.registered_entities
end
55 for k
,v
in pairs(list
[name
]) do
63 minetest
.register_node("arrow_signs:wall_right", {
64 description
= S("rightwards-pointing sign"),
65 drawtype
= "signlike",
66 tiles
= {"arrow_sign_right.png"},
67 inventory_image
= "arrow_sign_right.png",
69 paramtype2
= "wallmounted",
70 sunlight_propagates
= true,
74 --wall_top = <default>
75 --wall_bottom = <default>
76 --wall_side = <default>
78 groups
= {immortal
=1,attached_node
=1,arrow_sign
=1},
79 legacy_wallmounted
= true,
80 sounds
= default
.node_sound_defaults(),
81 on_construct
= function(pos
)
82 --local n = minetest.env:get_node(pos)
83 local meta
= minetest
.env
:get_meta(pos
)
84 meta
:set_string("formspec", "field[text;;${text}]")
85 meta
:set_string("infotext", "\"\"")
87 on_receive_fields
= function(pos
, formname
, fields
, sender
)
88 arrow_signs
:savetext(pos
, formname
, fields
, sender
)
90 on_punch
= function(pos
)
91 local meta
= minetest
.env
:get_meta(pos
)
92 meta
:set_string("formspec", "")
99 minetest
.register_node("arrow_signs:wall_left", {
100 description
= S("leftwards-pointing sign"),
101 drawtype
= "signlike",
102 tiles
= {"arrow_sign_left.png"},
103 inventory_image
= "arrow_sign_left.png",
105 paramtype2
= "wallmounted",
106 sunlight_propagates
= true,
109 type = "wallmounted",
110 --wall_top = <default>
111 --wall_bottom = <default>
112 --wall_side = <default>
114 groups
= {immortal
=1,attached_node
=1,arrow_sign
=1},
115 legacy_wallmounted
= true,
116 sounds
= default
.node_sound_defaults(),
117 on_construct
= function(pos
)
118 --local n = minetest.env:get_node(pos)
119 local meta
= minetest
.env
:get_meta(pos
)
120 meta
:set_string("formspec", "field[text;;${text}]")
121 meta
:set_string("infotext", "\"\"")
123 on_receive_fields
= function(pos
, formname
, fields
, sender
)
124 arrow_signs
:savetext(pos
, formname
, fields
, sender
)
126 on_punch
= function(pos
)
127 local meta
= minetest
.env
:get_meta(pos
)
128 meta
:set_string("formspec", "")
134 minetest
.register_node("arrow_signs:wall_up", {
135 description
= S("upwards-pointing sign"),
136 drawtype
= "signlike",
137 tiles
= {"arrow_sign_up.png"},
138 inventory_image
= "arrow_sign_up.png",
140 paramtype2
= "wallmounted",
141 sunlight_propagates
= true,
144 type = "wallmounted",
145 --wall_top = <default>
146 --wall_bottom = <default>
147 --wall_side = <default>
149 groups
= {immortal
=1,attached_node
=1,arrow_sign
=1},
150 legacy_wallmounted
= true,
151 sounds
= default
.node_sound_defaults(),
152 on_construct
= function(pos
)
153 --local n = minetest.env:get_node(pos)
154 local meta
= minetest
.env
:get_meta(pos
)
155 meta
:set_string("formspec", "field[text;;${text}]")
156 meta
:set_string("infotext", "\"\"")
158 on_receive_fields
= function(pos
, formname
, fields
, sender
)
159 arrow_signs
:savetext(pos
, formname
, fields
, sender
)
161 on_punch
= function(pos
)
162 local meta
= minetest
.env
:get_meta(pos
)
163 meta
:set_string("formspec", "")
169 minetest
.register_node("arrow_signs:wall_down", {
170 description
= S("downwards-pointing sign"),
171 drawtype
= "signlike",
172 tiles
= {"arrow_sign_down.png"},
173 inventory_image
= "arrow_sign_down.png",
175 paramtype2
= "wallmounted",
176 sunlight_propagates
= true,
179 type = "wallmounted",
180 --wall_top = <default>
181 --wall_bottom = <default>
182 --wall_side = <default>
184 groups
= {immortal
=1,attached_node
=1,arrow_sign
=1},
185 legacy_wallmounted
= true,
186 sounds
= default
.node_sound_defaults(),
187 on_construct
= function(pos
)
188 --local n = minetest.env:get_node(pos)
189 local meta
= minetest
.env
:get_meta(pos
)
190 meta
:set_string("formspec", "field[text;;${text}]")
191 meta
:set_string("infotext", "\"\"")
193 on_receive_fields
= function(pos
, formname
, fields
, sender
)
194 arrow_signs
:savetext(pos
, formname
, fields
, sender
)
196 on_punch
= function(pos
)
197 local meta
= minetest
.env
:get_meta(pos
)
198 meta
:set_string("formspec", "")
203 minetest
.register_abm( {
204 nodenames
= {"group:arrow_sign"},
207 action
= function(pos
, node
, active_object_count
, active_object_cound_wider
)
208 local meta
= minetest
.get_meta(pos
)
209 local original
= meta
:get_string("text")
210 if(original
~= "") then
211 meta
:set_string("infotext", S(original
))