Default furnace

User avatar
Johnny Joy
Member
 
Posts: 43
Joined: Fri Sep 05, 2014 20:26
GitHub: johnnyjoy
In-game: jjb

Default furnace

by Johnny Joy » Tue Apr 28, 2015 04:03

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
 

User avatar
Johnny Joy
Member
 
Posts: 43
Joined: Fri Sep 05, 2014 20:26
GitHub: johnnyjoy
In-game: jjb

Re: Default furnace

by Johnny Joy » Wed Apr 29, 2015 03:53

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
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 91 guests

cron