Jump to content

Game crashing


Recommended Posts

I'm working on a global mod and have created many things working, but once the new content just started to produce errors, do not run and "Crash." I tried to fix one mistake after another, but nothing helped. Then I decided to create a new item from the beginning. I did everything on their own patterns of objects (that worked!), But even when done correctly the game, when you start the game mode is simply crashing. Probably the thing in the picture, but here's a simple example of this problem. How can I solve crashes? What is the main mistake?

The image created for an example

P.S. Sorry for my English, I use a Google translator

Lamp.zip

Link to comment
Share on other sites

Just check your log.txt, it'll tell you where the game crashed. Also consider using print() for debugging (as seen in the game code)

 

What is that in the prefab file?

local function fn(colour)

    local function OnEquip(inst, owner)
        [...]
    end

    local function OnUnequip(inst, owner)
       [...]
    end

    local inst = CreateEntity()
    [...]

    return inst
end

return  Prefab("common/inventory/lamp", fn, assets, prefabs)

 

reposition this a bit, and remove the colour nonsense:

 

local function OnEquip(inst, owner)
        [...]
    end

    local function OnUnequip(inst, owner)
       [...]
    end

 

local function fn()
    local inst = CreateEntity()
    [...]

    return inst
end

return  Prefab("common/inventory/lamp", fn, assets, prefabs)

Link to comment
Share on other sites

Just check your log.txt, it'll tell you where the game crashed. Also consider using print() for debugging (as seen in the game code)

 

What is that in the prefab file?

local function fn(colour)

    local function OnEquip(inst, owner)

        [...]

    end

    local function OnUnequip(inst, owner)

       [...]

    end

    local inst = CreateEntity()

    [...]

    return inst

end

return  Prefab("common/inventory/lamp", fn, assets, prefabs)

 

reposition this a bit, and remove the colour nonsense:

 

local function OnEquip(inst, owner)

        [...]

    end

    local function OnUnequip(inst, owner)

       [...]

    end

 

local function fn()

    local inst = CreateEntity()

    [...]

    return inst

end

return  Prefab("common/inventory/lamp", fn, assets, prefabs)

So, I tried to remove the "colour nonsense", but instead of crushing, the game hangs in the menu, which states that the mod included.
It might be clearer if you look at the log file.
Only warning: error of all time I was VERY much :D 

log.txt

Link to comment
Share on other sites

You must have messed up then, it says that the end of "fn" there should be the file end, which means there is an "end" missplaced. Make sure that every "function" is paired with an "end".

 

...hang on, did you remove the entire line? In the second part of my post you can clearly see that only the "colour" is gone.

Link to comment
Share on other sites

You must have messed up then, it says that the end of "fn" there should be the file end, which means there is an "end" missplaced. Make sure that every "function" is paired with an "end".

 

...hang on, did you remove the entire line? In the second part of my post you can clearly see that only the "colour" is gone.

I've tried everything possible (and impossible) options. What am i doing wrong?

local assets=

{

Asset("ANIM", "anim/lamp.zip"),

Asset("ANIM", "anim/swap_lamp.zip"),

Asset("ATLAS", "images/inventoryimages/lamp.xml"),

Asset("IMAGE", "images/inventoryimages/lamp.tex"),

}

local prefabs =

{

}

local function OnEquip(inst, owner)

owner.AnimState:OverrideSymbol("swap_object", "swap_lamp", "swap_lamp")

owner.AnimState:Show("ARM_carry")

owner.AnimState:Hide("ARM_normal")

end

local function OnUnequip(inst, owner)

owner.AnimState:Hide("ARM_carry")

owner.AnimState:Show("ARM_normal")

end

local function fn()

local inst = CreateEntity()

local trans = inst.entity:AddTransform()

local anim = inst.entity:AddAnimState()

MakeInventoryPhysics(inst)

anim:SetBank("lamp")

anim:SetBuild("lamp")

anim:PlayAnimation("idle")

inst:AddComponent("inventoryitem")

inst.components.inventoryitem.imagename = "lamp"

inst.components.inventoryitem.atlasname = "images/inventoryimages/lamp.xml"

inst:AddComponent("equippable")

inst.components.equippable:SetOnEquip( OnEquip )

inst.components.equippable:SetOnUnequip( OnUnequip )

return inst

end

return Prefab("common/inventory/lamp", fn, assets, prefabs)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...