[solved] set_node error
I am working on a command for my mod, that update a node in the location specified through a chatcommand to the block specified. This should be pretty simple, but I'm trying to write it in a way that players don't get all the weird errors and get confused (like me), but instead get simple error messages through the chat.
I'm having two issues. When I run /update default:dirt 125 1.5 -26.2, I get "attempt to index a nil value," at line 39.
This line gets the type (node, craftitem, tool) for an if statement that confirms the type is node.
When I run the command the other way around, /update 125 1.5 -26.2 default:dirt, I get and error in the chat saying:
The /update functions accepts two values, name and param. player is then set from param, and node, p is set from param. Then I set item_string_type, for the if statement.
You can browse the code of the whole mod here, though functions.lua is missing several small fixes that I have not committed yet because of the above issues.
I'm having two issues. When I run /update default:dirt 125 1.5 -26.2, I get "attempt to index a nil value," at line 39.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local item_string_type = minetest.registered_items[node].type -- item string type
This line gets the type (node, craftitem, tool) for an if statement that confirms the type is node.
When I run the command the other way around, /update 125 1.5 -26.2 default:dirt, I get and error in the chat saying:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
2016-06-10 13:14:11: ERROR[Server]: Map::setNode(): Not allowing to place CONTENT_IGNORE while trying to replace "air" at (125,2,-26) (block (7,0,-2))
The /update functions accepts two values, name and param. player is then set from param, and node, p is set from param. Then I set item_string_type, for the if statement.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- variables
local player = minetest.get_player_by_name(name) -- player name
local node, p = string.match(param, "^([^ ]+) *(.*)$")
local p = minetest.string_to_pos(p)
local item_string_type = minetest.registered_items[node].type -- item string type
+
The full function called by /update:
You can browse the code of the whole mod here, though functions.lua is missing several small fixes that I have not committed yet because of the above issues.