LUA Error of custom Furnace

User avatar
CaKeSs
Member
 
Posts: 48
Joined: Sat Oct 13, 2012 02:48

LUA Error of custom Furnace

by CaKeSs » Sun Nov 11, 2012 07:34

Can anybody help me? I have a mod in progress here, but It has an error.

the Error is:

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
05:17:08: INFO[main]:   [alchemy     ] ["C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua"]
05:17:08: VERBOSE[main]: Loading and running script from C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua
05:17:08: ERROR[main]: ========== ERROR FROM LUA ===========
05:17:08: ERROR[main]: Failed to load and run script from
05:17:08: ERROR[main]: C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua:
05:17:08: ERROR[main]: ...est-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua:238: unfinished string near '"'
05:17:08: ERROR[main]: =======END OF ERROR FROM LUA ========
05:17:08: ERROR[main]: Server: Failed to load and run C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua
05:17:08: INFO[main]: BanManager: saving to C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\worlds\Dungeon's Might\ipban.txt
05:17:09: ERROR[main]: ModError: Failed to load and run C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua
05:17:09: INFO[main]: Searching worlds...
05:17:09: INFO[main]:   In C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\worlds:
05:17:09: INFO[main]: Adventure's Guild Dungeon's Might Quest of Faith
05:17:09: INFO[main]: 3 found.
05:17:09: INFO[main]: Waiting for other menus
05:17:09: INFO[main]: Waited for other menus
05:17:09: VERBOSE[main]: error_message = ModError: Failed to load and run C:\Zephyr Casts\Minetest\minetest-0.4.3-25cf375-win32\bin\..\games\minetest_game\mods\alchemy\init.lua


Here's the Mod code.

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
---Potion Flask mod
---By Michael<JusticeV; CaKeSs> <creslic_123@yahoo.com>
---

---

local flask_inactive_formspec =
    "invsize[8,9;]"..
    "image[2,2;1,1;default_furnace_fire_bg.png]"..
    "list[current_name;fuel;2,3;1,1;]"..
    "list[current_name;src;3,1;1,1;]"..
    "list[current_name;dst;5,1;2,2;]"..
    "list[current_player;main;0,5;8,4;]"

minetest.register_node("alchemy:flask", {
    description = "Flask",
    tiles = {"flask_top.png", "flask_bottom.png", "flask_side.png",
        "flask_side.png", "flask_side.png", "flask_front.png"},
    paramtype2 = "facedir",
    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", flask_inactive_formspec)
        meta:set_string("infotext", "Flask")
        local inv = meta:get_inventory()
        inv:set_size("fuel", 1)
        inv:set_size("src", 3)
        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("alchemy:flask_active", {
    description = "Flask",
    tiles = {"flask_top.png", "flask_bottom.png", "flask_side.png",
        "flask_side.png", "flask_side.png", "flask_front.png"},
    paramtype2 = "facedir",
    light_source = 8,
    drop = "alchemy:flask",
    groups = {cracky=2, not_in_creative_inventory=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("formspec", flask_inactive_formspec)
        meta:set_string("infotext", "Flask");
        local inv = meta:get_inventory()
        inv:set_size("fuel", 1)
        inv:set_size("src", 3)
        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 = {"alchemy:flask","alchemy:flask_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 Alchemized = nil
       
        if srclist then
            Alchemized = minetest.get_craft_result({method = "Alchemy", 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 Alchemized and Alchemized.item and meta:get_float("src_time") >= Alchemized.time then
                -- check if there's room for output in "dst" list
                if inv:room_for_item("dst",Alchemized.item) then
                    -- Put result in "dst" list
                    inv:add_item("dst", Alchemized.item)
                    -- take stuff from "src" list
                    srcstack = inv:get_stack("src", 1)
                    srcstack:take_item()
                    inv:set_stack("src", 1, srcstack)
                else
                    --print("Could not insert '"..Alchemized.item.."'")
                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","Alchemy active: "..percent.."%")
            hacky_swap_node(pos,"alchemy:flask")
            meta:set_string("formspec",
                "invsize[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 Alchemized = nil
        local fuellist = inv:get_list("fuel")
        local srclist = inv:get_list("src")
       
        if srclist then
            Alchemized = minetest.get_craft_result({method = "Alchemy", 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","Alchemy is out of power")
            hacky_swap_node(pos,"alchemy:flask")
            meta:set_string("formspec", oven_inactive_formspec)
            return
        end

        if cooked.item:is_empty() then
            if was_active then
                meta:set_string("infotext","Flask is empty")
                hacky_swap_node(pos,"alchemy:flask")
                meta:set_string("formspec", flask_inactive_formspec)
            end
            return
        end

        meta:set_string("fuel_totaltime", fuel.time)
        meta:set_string("fuel_time", 0)
       
        local stack = inv:get_stack("fuel", 1)
        stack:take_item()
        inv:set_stack("fuel", 1, stack)
    end,
})

---Items

minetest.register_craftitem("alchemy:apple_juice", {
description = "Apple juice",
inventory_image = "fulla_bottle.png",
on_use = minetest.item_eat(3.5),
})

minetest.register_craftitem("alchemy:potion", {
description = "Health potion",
inventory_image = "full_bottle.png",
on_use = minetest.item_eat(7),
})

minetest.register_craftitem("alchemy:empty_bottle", {
description = "Empty bottle",
inventory_image = "empty_bottle.png",
})

---Craft

minetest.register_craft({
    output = 'alchemy:empty_bottle',
    recipe = {
        {'', '', ''},
        {'', 'default:glass', ''},
        {'', 'default:glass', ''},
    }
})

minetest.register_craft({
    output = 'alchemy:furnace',
    recipe = {
        {'default:cobble', 'default:cobble', 'default:cobble'},
        {'default:cobble', 'default:lump_coal', 'default:cobble'},
        {'default:cobble', 'default:cobble', 'default:cobble'},
    }
})


---Alchemy recipes

minetest.register_craft({
    type = "Alchemy",
    output = "alchemy:potion","
    recipe = "alchemy:empty_bottle","bucket:bucket_lava","default:stick"
})

minetest.register_craft({
    type = "Alchemy",
    output = "alchemy:apple_juice","
    recipe = "alchemy:empty_bottle","bucket:bucket_water","default:apple"
})


Please tell me what to do.
lalalalala, Hit, dig, break, collect! -JusticeV before he fell in lava.
|Youtube||Unrealsoftware Account|Granite Mod|
 

jin_xi
Member
 
Posts: 165
Joined: Mon Jul 02, 2012 18:19

by jin_xi » Sun Nov 11, 2012 09:40

learn to look: the error message tells you this:

init.lua:238: unfinished string near '"'

looking there i find this:

---Alchemy recipes

minetest.register_craft({
type = "Alchemy",
output = "alchemy:potion","
recipe = "alchemy:empty_bottle","bucket:bucket_lava","default:stick"
})

see the error yet? that line with output has an extra " after the comma, so remove it.
 

User avatar
CaKeSs
Member
 
Posts: 48
Joined: Sat Oct 13, 2012 02:48

by CaKeSs » Sun Nov 11, 2012 09:42

Oh I see. Thanks!
lalalalala, Hit, dig, break, collect! -JusticeV before he fell in lava.
|Youtube||Unrealsoftware Account|Granite Mod|
 

sky
Member
 
Posts: 152
Joined: Tue Oct 16, 2012 11:59

by sky » Sun Nov 11, 2012 09:44

cakess make this a mod every one will want it , me toooooooooooooooooooo, this is what minetest needs poition brewing(alchemy)
Last edited by sky on Sun Nov 11, 2012 09:44, 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 Nov 11, 2012 09:56

CaKeSs, I saw that you need some help with creating this mod. So you asked on the forum for help (that is actually a good solution). But please dont create a new topic for every single question.
 

User avatar
CaKeSs
Member
 
Posts: 48
Joined: Sat Oct 13, 2012 02:48

by CaKeSs » Sun Nov 11, 2012 10:01

Okay Adam.
lalalalala, Hit, dig, break, collect! -JusticeV before he fell in lava.
|Youtube||Unrealsoftware Account|Granite Mod|
 

sky
Member
 
Posts: 152
Joined: Tue Oct 16, 2012 11:59

by sky » Sun Nov 11, 2012 10:40

PilzAdam wrote: But please dont create a new topic for every single question.

you said that to me to plizadam
 


Return to WIP Mods

Who is online

Users browsing this forum: Google [Bot] and 7 guests

cron