Food item API?

Post Reply
User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Food item API?

by Joseph16 » Post

I know if you want to make a new note you type Minetest.register.node in init.lua but can someone give me a API for creating and eatable item? I making a food mod that adds one single item in and I need to know what I need to put in order for it to work: how much Health it refills, and how to make it register as an eatable item. Thanks! EDIT: I figured it out.
Testin' mines since 1989

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Food item API?

by kaeza » Post

A small note: always follow up with a brief note on the solution (Related xkcd).

For the benefit of other users, you should use `minetest.item_eat` like so:

Code: Select all

minetest.register_whatever("foobar", {
  -- ... Other fields here
  -- hp_to_restore is in half-heart units.
  -- 1 heals half a heart, 2 heals a full heart, and so on.
  on_use = minetest.item_eat(hp_to_restore),
})
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests