Page 1 of 1

Default furnace

PostPosted: Tue Apr 28, 2015 04:03
by Johnny Joy
I notices in default/furnace.lua that the abm action for furnaces, that runs once per second, initialize the inventories for the furnace each time. Unless I'm missing something the inventories numbers are not going to change at all once the furnace is created. Am I missing something?

I'm going to move the initialization to node placement, and experiment.

Code in question.
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
        --
        -- Inizialize inventory
        --
        local inv = meta:get_inventory()

        for listname, size in pairs({
                        src     = 1,
                        fuel    = 1,
                        dst     = 4,
        }) do
                if inv:get_size(listname) ~= size then
                        inv:set_size(listname, size)
                end
        end

Re: Default furnace

PostPosted: Wed Apr 29, 2015 03:53
by Johnny Joy
I noticed the look that sets the size for the 3 inventories was in a loop which was overly complex for what needed to be done. Must have been tired not to notice that at first. This is how it looks now. I hope it's a little more clean.

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 function after_place_node(pos, placer, itemstack, pointed_thing)
        --
        -- Inizialize metadata
        --
        local meta = minetest.get_meta(pos)
        --
        -- Inizialize inventory
        --
        local inv = meta:get_inventory()

        inv:set_size("src", 1)
        inv:set_size("fuel", 1)
        inv:set_size("dst", 4)

        end

end