logalog42 / minegistics

a minetest game for minetest game jam
GNU General Public License v3.0
8 stars 5 forks source link

Game crashes #38

Open Escuadrin opened 1 year ago

Escuadrin commented 1 year ago

The game crashes and Debug says this :

2023-06-17 13:25:50: WARNING[Server]: Undeclared global variable "Refinery_recipes" accessed at ...ames\minegistic\mods\minegistics\structures\workshop.lua:118 2023-06-17 13:25:51: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'minegistics' in callback LuaABM::trigger(): ...ames\minegistic\mods\minegistics\structures\workshop.lua:118: attempt to index global 'Refinery_recipes' (a nil value) 2023-06-17 13:25:51: ERROR[Main]: stack traceback: 2023-06-17 13:25:51: ERROR[Main]: ...ames\minegistic\mods\minegistics\structures\workshop.lua:118: in function <...ames\minegistic\mods\minegistics\structures\workshop.lua:101> 2023-06-17 13:25:51: ACTION[Main]: Server: Shutting down

logalog42 commented 1 year ago

How did you install the pack? Was it through the content tab in minetest, download from minetest.content, or from github itself?

Escuadrin commented 1 year ago

from contentdb, maybe the error is because i had the old version installed i will try to delete and reinstall it

logalog42 commented 1 year ago

Yeah sorry about that. I did some rather major overhauls so it's possible that updating didn't implement all the changes it needed to.

Escuadrin commented 1 year ago

Deletin and reinstalling the game seemed to fix it. Other bugs i noticed are: You can spawn stuck inside a mountain, apparently i cant destroy workshops and when you die all the trains die. Hope that helps :)

ik160 commented 1 year ago

The error message says "It should be "workshop_recipes" and not to be Refinery_recipes in line:118. And workshop has two outputs (it's interesting). I tried to modify your code as below, and really enjoy! FYI. new workshop.lua: line:113-125 for input, output in pairs(RecipiesInStructure.Workshop) do --items[input] = ItemStack(input) items[input] = ItemStack(input) product1[input] = ItemStack(output[1]) product2[input] = ItemStack(output[2])

            end
            local inventories = inv:get_lists()
            for name, list in pairs(inventories) do
                for index, item in pairs(items) do
                    while inv:contains_item(name, item) do
                        local item_name = item:get_name()
                        local product1 = product1[item_name]
                        local stack1 = ItemStack(product1)
                        local product2 = product2[item_name]
                        local stack2 = ItemStack(product2)
                        inv:remove_item(name, item)
                        inv:add_item("output", stack1)
                        inv:add_item("output", stack2)
                        working = true
                    end
                end
            end
logalog42 commented 1 year ago

Thanks ik160 it looks like because of the changes I made to organization you'll need to uninstall and reinstall it to make it work. I will be comparing code to see which way would be better.

Kazooo100 commented 5 months ago

I have this crash aswell. Installed today from contentdb in game Attempting to add ik160's fix doesnt help sadly

Reinstalling from github also doesnt help. It crashes as soon as I have a workshop running.

Kazooo100 commented 5 months ago

I found a fix

replace 109-1 with:

                            local working = false
            local product1 = {}
            local product2 = {}
            for input, output in pairs(RecipiesInStructure.Workshop) do
                items[input] = ItemStack(input)
                product1[input] = ItemStack(output[1])
                product2[input] = ItemStack(output[2])
                --print("product1 inoutpairs"..tostring(product1))
            end
            local inventories = inv:get_lists()
            for name, list in pairs(inventories) do
                for index, item in pairs(items) do
                    while inv:contains_item(name, item) do
                    local item_name = item:get_name()
                    local product1 = product1[item_name]
                    local stack1 = ItemStack(product1)
                    local product2 = product2[item_name]
                    local stack2 = ItemStack(product2)

                    inv:remove_item(name, item)
                    inv:add_item("output", product1)
                    inv:add_item("output", stack2)
                    working = true
                    end
                end
            end
Githubismalware commented 3 months ago

I got this error too while trying to connect a refinery to a workshop using a train and track. When the train put a lump into the workshop, the ~10 second ticking time bomb started. I realised later that the workshop was the culprit, so tried to remove it but couldn't break it even though it had no items. I eventually needed to pull out the super pickaxe since simply reinstalling the game didn't work, which destroyed it (along with the ground) with ease and stopped the loop.

Kazooo100 commented 3 months ago

I got this error too while trying to connect a refinery to a workshop using a train and track. When the train put a lump into the workshop, the ~10 second ticking time bomb started. I realised later that the workshop was the culprit, so tried to remove it but couldn't break it even though it had no items. I eventually needed to pull out the super pickaxe since simply reinstalling the game didn't work, which destroyed it (along with the ground) with ease and stopped the loop.

Reinstalling didn't work for me either, I put a fix above. It might work for you? Factories also don't work but don't crash, they just steal your items and produce nothing.

jparish1977 commented 3 months ago

one problem with (I think it's a problem) after Kazooo100 fix: it processes everything in the inventory at the same time.... if you adjust the while you can eliminate that: `

local inventories = inv:get_lists()
for name, list in pairs(inventories) do
    for index, item in pairs(items) do
               -- only let it work on one at a time
        while not working and inv:contains_item(name, item) do
            local item_name = item:get_name()