Food item API?

User avatar
Posts: 308
Joined: Tue Dec 06, 2016 05:35
In-game: Joseph16

Food item API?

by Joseph16 » Fri Apr 14, 2017 23:29

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
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
Location: Montevideo, Uruguay
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Food item API?

by kaeza » Sat Apr 22, 2017 19:33

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

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 1 guest