Hotbar - Adding default items

Post Reply
antics
New member
Posts: 2
Joined: Wed Feb 10, 2021 10:38
GitHub: antics

Hotbar - Adding default items

by antics » Post

Hi guys, my first post!

I would like to give a default item to new users entering the world.

Is the code below the correct way to go about doing this; if I (i.e.) would like to give them the "Clay" item?

Code: Select all

minetest.register_on_joinplayer(function(player)
    local item = ItemStack("clay")
    player:get_inventory():set_stack("main", 1, item)
end)
Also, where can I find a list of the item-definitions (names) for items in the Minetest game?

I am completely new to Lua and the Minetest API, and in the process of customizing a game to be used in a virtual educational drama setting.

Thanks!

antics
New member
Posts: 2
Joined: Wed Feb 10, 2021 10:38
GitHub: antics

Re: Hotbar - Adding default items

by antics » Post

Answering myself as I managed to work it out with a small change to the code (default:clay):

Code: Select all

minetest.register_on_joinplayer(function(player)
    local item = ItemStack("default:clay")
    player:get_inventory():set_stack("main", 1, item)
end)
I put the code in ~/.minetest/worlds/myworld/worldmods/inventory/init.lua
(as explained in https://rubenwardy.com/minetest_modding ... arted.html)

For a list of generated blocks I found this page where each page lists the Itemstring for each block: https://wiki.minetest.net/Category:Generated_blocks

User avatar
Nathan.S
Member
Posts: 1065
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: Hotbar - Adding default items

by Nathan.S » Post

If you are using Minetest_game you can add these two lines to your Minetest.conf file,

Code: Select all

give_initial_stuff = true
initial_stuff = "default:dirt 15,default:stone 99"
If you want a list of items/nodes you'd probably be best off installing a craftguide mod that provides those strings in game.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests