You're using the wrong quote marks. You should edit in notepad++, gedit, atom or another code editor (must be text based).
This is the right quote: "
You're also missing "end", it should look like this:
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
on_use = function(itemstack, user, pointed_thing)
-- content here
end
You're also missing user: from set_hp():
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
and you're missing () and user: from get_hp:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
and it should be
if itemstack
:take_item()
~= nil thenYou can use minetest.item_eat to eat an item and increase hp (although if hunger is installed the hunger is satisfied)
There is a comma missing from the end of line 3:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
and this line
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
also, where is hp_max defined? What do you want to do?
You don't need a file extension for textures, it looks for them automatically if you don't.
http://rubenwardy.com/minetest_modding_ ... l#texturesYou should use indentation.
Fixed code
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
minetest.register_node("superpotato:potato", {
description = "Potato",
inventory_image = "nonspotato",
wield_image = "nonspotato",
wield_scale = 50,
stack_max = 99,
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if itemstack.take_item() ~= nil then
user:set_hp(user:get_hp()+10)
return itemstack
end
end
})
minetest.register_craftitem("superpotato:superpotato", {
description = "Le Super Potato",
inventory_image = "superpotato",
wield_image = "superpotato",
wield_scale =50,
stack_max = 1,
liquids_pointable = false,
on_use = function(itemstack, user, pointed_thing)
if itemstack:take_item() ~= nil then
math.randomseed(os.time())
local hp_max = hp_max+random(5)
user:set_hp(hp_max)
return itemstack
end
end
})
minetest.register_craft({
type = "fuel",
recipe = "supercoal:supercoal",
burntime = 20
})
minetest.register_craft({
output = 'superpotato:superpotato 2',
recipe = {
{'default:diamond', 'default:gold','default:coal'},
{'default:mese', 'superpotato:potatoblock', 'default:wood'},
{default:steel'', 'default:dirt', 'default:sand'},
}
})
Better code
This uses minetest.item_eat and minetest.do_item_eat to increase hp, is better, supports hunger.
minetest.do_item_eatYour 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
minetest.register_node("superpotato:potato", {
description = "Potato",
inventory_image = "nonspotato",
wield_image = "nonspotato",
wield_scale = 50,
stack_max = 99,
liquids_pointable = true,
on_use = minetest.item_eat(10)
})
minetest.register_craftitem("superpotato:superpotato", {
description = "Le Super Potato",
inventory_image = "superpotato",
wield_image = "superpotato",
wield_scale =50,
stack_max = 1,
liquids_pointable = false,
on_use = function(itemstack, user, pointed_thing)
-- not sure what you want to do here,
-- this increases hp by a random number
math.randomseed(os.time())
return minetest.do_item_eat(random(5), nil, itemstack, user, pointed_thing)
end
})
minetest.register_craft({
type = "fuel",
recipe = "supercoal:supercoal",
burntime = 20
})
minetest.register_craft({
output = 'superpotato:superpotato 2',
recipe = {
{'default:diamond', 'default:gold','default:coal'},
{'default:mese', 'superpotato:potatoblock', 'default:wood'},
{default:steel'', 'default:dirt', 'default:sand'},
}
})