adding items to inventory...or not
i copy and pasted this code from
however it doesnt work but this code in a function...
does work...i have been staring at it now for a few hours and at the root of things i see no difference .. so why does the first one not work and the second one does?
http://rubenwardy.com/minetest_modding_book/chapters/inventories.html
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 stack = ItemStack("default:coal_lump 99")
local leftover = ninv:add_item("main", stack)
however it doesnt work but this code in a function...
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
setstackcount = function(pos, invin, name, count)
local inv = minetest.get_meta(pos):get_inventory()
local found = tbmroad.getstackcount(pos, name) + count
local numberofstacks = math.floor(found / 99)
local laststacksize = found % 99
local h = 0
for h = 1, numberofstacks do
inv:add_item(invin, name.." 99")
end
inv:add_item(invin, name.." "..laststacksize)
end
does work...i have been staring at it now for a few hours and at the root of things i see no difference .. so why does the first one not work and the second one does?