help plz error with my mod! SOLVED

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

help plz error with my mod! SOLVED

by durtective6 » Sun Oct 27, 2013 13:28

i was trying to make a mod which includes a furnace but when making part of the code and testing it this came up
Image
what should i do
(sorry if this is informal it was a rushed question)
if its needed i can supply the code.
note: i looked at other mods to make my furnace have different features e.g. animations
Last edited by durtective6 on Sun Oct 27, 2013 14:41, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Oct 27, 2013 13:39

What Minetest version do you have?
Can you paste the mod code?
 

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

by durtective6 » Sun Oct 27, 2013 13:47

0.4.7
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
minetest.register_craft({
        output = "techno:technocooker",
        recipe = {
        {'', 'default:obsidian', ''},
                {'default:obsidian', 'default:torch', 'default:obsidian'},
                {'', 'default:obsidian', ''},
    }
})

minetest.register_node("techno:technocooker", {
        description = "technocooker",
        drawtype = "plantlike",
        tiles = {"technocooker_no.png"},
        walkable=true,
        sunlight_propogates=true,
        paramtype="light",
        paramtype2 = "facedir",
        groups = {oddly_breakable_by_hand=1},
        legacy_facedir_simple = true,
        sounds = default.node_sound_stone_defaults(),
        on_construct = function(pos)
                local meta = minetest.env:get_meta(pos)
                meta:set_string("infotext", "technocooker")
                local inv = meta:get_inventory()
                inv:set_size("fuel", 1)
                inv:set_size("src", 1)
                inv:set_size("dst", 4)
        end,
        can_dig = function(pos,player)
                local meta = minetest.env:get_meta(pos);
                local inv = meta:get_inventory()
                if not inv:is_empty("fuel") then
                        return false
                elseif not inv:is_empty("dst") then
                        return false
                elseif not inv:is_empty("src") then
                        return false
                end
                return true
        end,
})

minetest.register_node("techno:technocooker_active", {
        description = "technocooker active",
        drawtype = "plantlike",
        tiles = {{name="technocooker.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=3.0}}},
        light_source = 9,
        paramtype="light",
        walkable=true,
        drop = "techno:technocooker",
        groups = {cracky=2},
        legacy_facedir_simple = true,
        sounds = default.node_sound_stone_defaults(),
        on_construct = function(pos)
                local meta = minetest.env:get_meta(pos)
                meta:set_string("formspec", default.furnace_inactive_formspec)
                meta:set_string("infotext", "Furnace");
                local inv = meta:get_inventory()
                inv:set_size("fuel", 1)
                inv:set_size("src", 1)
                inv:set_size("dst", 4)
        end,
        can_dig = function(pos,player)
                local meta = minetest.env:get_meta(pos);
                local inv = meta:get_inventory()
                if not inv:is_empty("fuel") then
                        return false
                elseif not inv:is_empty("dst") then
                        return false
                elseif not inv:is_empty("src") then
                        return false
                end
                return true
        end,
})

function hacky_swap_node(pos,name)
        local node = minetest.env:get_node(pos)
        local meta = minetest.env:get_meta(pos)
        local meta0 = meta:to_table()
        if node.name == name then
                return
        end
        node.name = name
        local meta0 = meta:to_table()
        minetest.env:set_node(pos,node)
        meta = minetest.env:get_meta(pos)
        meta:from_table(meta0)
end

minetest.register_abm({
        nodenames = {"techno:technocooker","techno:technocooker_active"},
        interval = 1.0,
        chance = 1,
        action = function(pos, node, active_object_count, active_object_count_wider)
                local meta = minetest.env:get_meta(pos)
                for i, name in ipairs({
                                "fuel_totaltime",
                                "fuel_time",
                                "src_totaltime",
                                "src_time"
                }) do
                        if meta:get_string(name) == "" then
                                meta:set_float(name, 0.0)
                        end
                end

                local inv = meta:get_inventory()

                local srclist = inv:get_list("src")
                local cooked = nil
               
                if srclist then
                        cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
                end
               
                local was_active = false
               
                if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
                        was_active = true
                        meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
                        meta:set_float("src_time", meta:get_float("src_time") + 1)
                        if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
                                -- check if there's room for output in "dst" list
                                if inv:room_for_item("dst",cooked.item) then
                          inv:add_item("dst", cooked.item)
                                        srcstack = inv:get_stack("src", 1)
                                        srcstack:take_item()
                                        inv:set_stack("src", 1, srcstack)
                                else
                                        print("Could not insert '"..cooked.item:to_string().."'")
                                end
                                meta:set_string("src_time", 0)
                        end
                end
               
                if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
                        local percent = math.floor(meta:get_float("fuel_time") /
                                        meta:get_float("fuel_totaltime") * 100)
                        meta:set_string("infotext","Furnace active: "..percent.."%")
                        hacky_swap_node(pos,"techno:technocooker_active")
                        meta:set_string("formspec",
                                "size[8,9]"..
                                "image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
                                                (100-percent)..":default_furnace_fire_fg.png]"..
                                "list[current_name;fuel;2,3;1,1;]"..
                                "list[current_name;src;2,1;1,1;]"..
                                "list[current_name;dst;5,1;2,2;]"..
                                "list[current_player;main;0,5;8,4;]")
                        return
                end

                local fuel = nil
                local cooked = nil
                local fuellist = inv:get_list("fuel")
                local srclist = inv:get_list("src")
               
                if srclist then
                        cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
                end
                if fuellist then
                        fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
                end

                if fuel.time <= 0 then
                        meta:set_string("infotext","empty/finished cooking")
                        hacky_swap_node(pos,"techno:technocooker")
                        meta:set_string("formspec", default.furnace_inactive_formspec)
                        return
                end

                if cooked.item:is_empty() then
                        if was_active then
                                meta:set_string("infotext","technocooker is empty")
                                hacky_swap_node(pos,"techno:technocooker")
                                meta:set_string("formspec", default.furnace_inactive_formspec)
                        end
                        return
                end

                meta:set_string("fuel_totaltime", fuel.time)
                meta:set_string("fuel_time", 0)
               
                inv:set_stack("fuel", 1, afterfuel.items[1])
        end,
})
 

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

by durtective6 » Sun Oct 27, 2013 14:04

after adding some code, and testing i got this error which refers to the afterfuel
Image
o yea the game mode is one i put together to test mods, as my other modes had to many mods to tell if a error is coming specifically from mine :P
Last edited by durtective6 on Sun Oct 27, 2013 14:05, edited 1 time in total.
 

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

by durtective6 » Sun Oct 27, 2013 14:29

k soooo i re wrote the entire code but now, when active it looks like this
Image
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron