local HEALTH = 4 -- min health of the player in 1/2 hearts to get help
minetest.register_node("modname:help_node", {
-- normal stuff here
on_punch = function(pos, node, puncher)
if puncher:get_hp() <= HEALTH then
player:get_inventory():add_item("main", ItemStack("default:apple"))
end
end
})webdesigner97 wrote:thx, I'll try it. Another question: When working with nodeboxes, is it possible to use multiple textures? For the emergency phone, I've got an orange background, a "SOS" text, and a phone-graphic. How can I place them on the nodebox on the right position?
local HEALTH = 4
-- Emergency Phone
minetest.register_node("streets:emergency_phone", {
description = "Emergency Phone",
tile_images = {"streets_sos_bg.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=3},
node_box = {
type = "fixed",
fixed = {{-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}, {0.3, 0.5, 0.3, -0.3, 1.4, -0.3}, {0.35, 1.4, 0.35, -0.35, 1.5, -0.35}}
}
on_punch = function(pos, node, puncher)
if puncher:get_hp() <= HEALTH then
player:get_inventory():add_item("main", ItemStack("default:apple"))
end
end
})
16:56:06: INFO[main]: [streets ] ["C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua"]
16:56:06: VERBOSE[main]: Loading and running script from C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua
16:56:06: ERROR[main]: ========== ERROR FROM LUA ===========
16:56:06: ERROR[main]: Failed to load and run script from
16:56:06: ERROR[main]: C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua:
16:56:06: ERROR[main]: ...est-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua:110: '}' expected (to close '{' at line 99) near 'on_punch'
16:56:06: ERROR[main]: =======END OF ERROR FROM LUA ========
16:56:06: ERROR[main]: Server: Failed to load and run C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua
16:56:06: INFO[main]: BanManager: saving to C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\worlds\Modding Area\ipban.txt
16:56:06: ERROR[main]: ModError: Failed to load and run C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua
16:56:06: INFO[main]: Searching worlds...
16:56:06: INFO[main]: In C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\worlds:
16:56:06: INFO[main]: (invalid: min) Modding Area StreetsModExample test
16:56:06: INFO[main]: 3 found.
16:56:06: INFO[main]: Waiting for other menus
16:56:06: INFO[main]: Waited for other menus
16:56:06: VERBOSE[main]: error_message = ModError: Failed to load and run C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\mods\minetest\streets\init.lua
16:56:06: VERBOSE[main]: Check debug.txt for details.
16:56:06: INFO[main]: Created main menu
16:56:06: INFO[main]: locale has been set to:German_Germany.1252
16:56:06: INFO[main]: locale has been set to:C
16:56:08: INFO[main]: locale has been set to:German_Germany.1252
16:56:08: INFO[main]: locale has been set to:C
16:56:09: INFO[main]: Dropping main menu
16:56:09: INFO[main]: Updating configuration file: "C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\minetest.conf"
16:56:09: INFO[main]: Skipping writing of C:\Program Files (x86)\Minetest-c55 Win32\minetest-0.4.1-win32\bin\..\minetest.conf because content wouldn't be modified
PilzAdam wrote:webdesigner97 wrote:thx, I'll try it. Another question: When working with nodeboxes, is it possible to use multiple textures? For the emergency phone, I've got an orange background, a "SOS" text, and a phone-graphic. How can I place them on the nodebox on the right position?
The textures are "painted" on the nodeboxes the same way it is in normal nodes. So every little box will have a part of the x+ texture of the node; you can not define little textures for all little boxes.
webdesigner97 wrote:I get an error message with this code:local HEALTH = 4
-- Emergency Phone
minetest.register_node("streets:emergency_phone", {
description = "Emergency Phone",
tile_images = {"streets_sos_bg.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=3},
node_box = {
type = "fixed",
fixed = {{-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}, {0.3, 0.5, 0.3, -0.3, 1.4, -0.3}, {0.35, 1.4, 0.35, -0.35, 1.5, -0.35}}
},
on_punch = function(pos, node, puncher)
if puncher:get_hp() <= HEALTH then
player:get_inventory():add_item("main", ItemStack("default:apple"))
end
end
})
webdesigner97 wrote:PilzAdam wrote:webdesigner97 wrote:thx, I'll try it. Another question: When working with nodeboxes, is it possible to use multiple textures? For the emergency phone, I've got an orange background, a "SOS" text, and a phone-graphic. How can I place them on the nodebox on the right position?
The textures are "painted" on the nodeboxes the same way it is in normal nodes. So every little box will have a part of the x+ texture of the node; you can not define little textures for all little boxes.
:( So something like this isn't possible?
PilzAdam wrote:webdesigner97 wrote:PilzAdam wrote:The textures are "painted" on the nodeboxes the same way it is in normal nodes. So every little box will have a part of the x+ texture of the node; you can not define little textures for all little boxes.
:( So something like this isn't possible?
Maybe, buts its tricky.
webdesigner97 wrote:New problem: When I define one texture for the nodebox, a part of it uses a texture of another mod! Why?!
PilzAdam wrote:webdesigner97 wrote:New problem: When I define one texture for the nodebox, a part of it uses a texture of another mod! Why?!
Can you explain it better? Screenshots?

PilzAdam wrote:webdesigner97 wrote:I get an error message with this code:local HEALTH = 4
-- Emergency Phone
minetest.register_node("streets:emergency_phone", {
description = "Emergency Phone",
tile_images = {"streets_sos_bg.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=3},
node_box = {
type = "fixed",
fixed = {{-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}, {0.3, 0.5, 0.3, -0.3, 1.4, -0.3}, {0.35, 1.4, 0.35, -0.35, 1.5, -0.35}}
},
on_punch = function(pos, node, puncher)
if puncher:get_hp() <= HEALTH then
player:get_inventory():add_item("main", ItemStack("default:apple"))
end
end
})
webdesigner97 wrote:PilzAdam wrote:webdesigner97 wrote:New problem: When I define one texture for the nodebox, a part of it uses a texture of another mod! Why?!
Can you explain it better? Screenshots?
Sry, not mod, but node. Screenshot:
webdesigner97 wrote:ok, but again a problem with your code :(
player:get_inventory():add_item("main", ItemStack("default:apple"))
--> game crashes when punching with "attempt to index"
PilzAdam wrote:webdesigner97 wrote:ok, but again a problem with your code :(
player:get_inventory():add_item("main", ItemStack("default:apple"))
--> game crashes when punching with "attempt to index"
ooops... it has to be puncher instead of player.
webdesigner97 wrote:Ok, maybe I could modify the health without apples (cheating!), is there a way to change health with code?
puncher:set_hp(puncher:get_hp()+2)
Users browsing this forum: No registered users and 18 guests