Jump to content

Could someone lend me a hand here


Prince143

Recommended Posts

I'm making a mod called "BETTER TORCH" , while equip it makes the player warm. After I craft the Torch the game crashed and this log appeared and I don't have any idea how to fix this, could someone fix this for me? You could take all over the mod and own it and I don't care just to make it real!
 

LOG
                                                          

...1.104670 with DLC/data/scripts/components/fueled.lua:156: attempt to compare number with nil
LUA ERROR stack traceback:
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/fueled.lua(156,1) in function 'InitializeFuelLevel'
C:/Games/Dont Starve v1.104670 with DLC/data/../mods/Better Torch/scripts/prefabs/torch.lua(135,1) in function 'fn'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(126,1)
=[C] in function 'SpawnPrefab'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(160,1) in function 'SpawnPrefab'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/builder.lua(300,1) in function 'DoBuild'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/actions.lua(637,1) in function 'fn'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/bufferedaction.lua(19,1) in function 'Do'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/entityscript.lua(942,1) in function 'PerformBufferedAction'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraphs/SGwilson.lua(1609,1) in function 'ontimeout'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(458,1) in function 'UpdateState'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(515,1) in function 'Update'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(111,1) in function 'Update'
C:/Games/Dont Starve v1.104670 with DLC/data/scripts/update.lua(127,1)

 

PREFAB TORCH.LUA

 

local assets =
{
Asset("ANIM", "anim/torch.zip"),
Asset("ANIM", "anim/swap_torch.zip"),
Asset("SOUND", "sound/common.fsb"),
}

local prefabs =
{
"torchfire",
}


local function onequip(inst, owner)
--owner.components.combat.damage = TUNING.PICK_DAMAGE
inst.components.burnable:Ignite()
owner.AnimState:OverrideSymbol("swap_object", "swap_torch", "swap_torch")
owner.AnimState:Show("ARM_carry")
owner.AnimState:Hide("ARM_normal")

inst.SoundEmitter:PlaySound("dontstarve/wilson/torch_LP", "torch")
inst.SoundEmitter:PlaySound("dontstarve/wilson/torch_swing")
inst.SoundEmitter:SetParameter( "torch", "intensity", 1 )

inst.fire = SpawnPrefab( "torchfire" )
local follower = inst.fire.entity:AddFollower()
follower:FollowSymbol( owner.GUID, "swap_object", 0, -110, 1 )
--inst.fire.persists = false
--take a percent of fuel next frame instead of this one, so we can remove the torch properly if it runs out at that point
inst:DoTaskInTime(0, function()
if inst.components.fueled.currentfuel < inst.components.fueled.maxfuel then
inst.components.fueled:DoDelta(-inst.components.fueled.maxfuel*.01)
end
end)
end



local function onunequip(inst,owner)
inst.fire:Remove()
inst.fire = nil

inst.components.burnable:Extinguish()
owner.components.combat.damage = owner.components.combat.defaultdamage
owner.AnimState:Hide("ARM_carry")
owner.AnimState:Show("ARM_normal")
inst.SoundEmitter:KillSound("torch")
inst.SoundEmitter:PlaySound("dontstarve/common/fireOut")
end


local function fn(Sim)
local inst = CreateEntity()
local trans = inst.entity:AddTransform()
local anim = inst.entity:AddAnimState()
local sound = inst.entity:AddSoundEmitter()
anim:SetBank("torch")
anim:SetBuild("torch")
anim:PlayAnimation("idle")
MakeInventoryPhysics(inst)

inst:AddComponent("weapon")
inst.components.weapon:SetDamage(TUNING.TORCH_DAMAGE)
inst.components.weapon:SetAttackCallback(
function(attacker, target)
if target.components.burnable then
if math.random() < TUNING.TORCH_ATTACK_IGNITE_PERCENT*target.components.burnable.flammability then
target.components.burnable:Ignite()
end
end
end
)


-----------------------------------
inst:AddComponent("lighter")
-----------------------------------

inst:AddComponent("inventoryitem")
-----------------------------------

inst:AddComponent("equippable")

inst.components.equippable:SetOnPocket( function(owner) inst.components.burnable:Extinguish() end)

inst.components.equippable:SetOnEquip( onequip )

inst.components.equippable:SetOnUnequip( onunequip )


-----------------------------------

inst:AddComponent("inspectable")

-----------------------------------

inst:AddComponent("burnable")
inst.components.burnable.canlight = false
inst.components.burnable.fxprefab = nil
--inst.components.burnable:AddFXOffset(Vector3(0,1.5,-.01))

-----------------------------------

inst:AddComponent("fueled")


inst.components.fueled:SetUpdateFn( function()
if GetSeasonManager():IsRaining() then
inst.components.fueled.rate = 1 + TUNING.TORCH_RAIN_RATE*GetSeasonManager():GetPrecipitationRate()
else
inst.components.fueled.rate = 1
end
end)


inst.components.fueled:SetSectionCallback(
function(section)
if section == 0 then
--when we burn out
if inst.components.burnable then
inst.components.burnable:Extinguish()
end

if inst.components.inventoryitem and inst.components.inventoryitem:IsHeld() then
local owner = inst.components.inventoryitem.owner
inst:Remove()

if owner then
owner:PushEvent("torchranout", {torch = inst})
end
end

end
end)
inst.components.fueled:InitializeFuelLevel(TUNING.COLDTORCH_FUEL)
inst.components.fueled:SetDepletedFn(function(inst) inst:Remove() end)

return inst
end

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

 

Link to comment
Share on other sites

You are trying to compare a nil variable with a number which is like dividing by zero.

 

The issue is caused when you InitialiFuelLevel, TUNING.COLDTORCH_FUEL should be a GLOBAL variable...GLOBAL.TUNING.COLDTORCH_FUEL.

 

You can see this information based on these two lines:

...1.104670 with DLC/data/scripts/components/fueled.lua:156: attempt to compare number with nilLUA ERROR stack traceback:C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/fueled.lua(156,1) in function 'InitializeFuelLevel'

The first line tells you the error and the second line tells you in which function.

Link to comment
Share on other sites

You are trying to compare a nil variable with a number which is like dividing by zero.

 

The issue is caused when you InitialiFuelLevel, TUNING.COLDTORCH_FUEL should be a GLOBAL variable...GLOBAL.TUNING.COLDTORCH_FUEL.

 

You can see this information based on these two lines:

...1.104670 with DLC/data/scripts/components/fueled.lua:156: attempt to compare number with nilLUA ERROR stack traceback:C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/fueled.lua(156,1) in function 'InitializeFuelLevel'

The first line tells you the error and the second line tells you in which function.

 

Okay , after I put the GLOBAL in , and after I crafted a torch the game crashed again. ANOTHER NEW LOG CRASH AGAIN.

 

...LC/data/../mods/New folder/scripts/prefabs/torch.lua:135: variable 'GLOBAL' is not declared
LUA ERROR stack traceback:
        =[C] in function 'error'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/strict.lua(23,1)
        C:/Games/Dont Starve v1.104670 with DLC/data/../mods/New folder/scripts/prefabs/torch.lua(135,1) in function 'fn'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(126,1)
        =[C] in function 'SpawnPrefab'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(160,1) in function 'SpawnPrefab'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/builder.lua(300,1) in function 'DoBuild'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/actions.lua(637,1) in function 'fn'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/bufferedaction.lua(19,1) in function 'Do'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/entityscript.lua(942,1) in function 'PerformBufferedAction'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraphs/SGwilson.lua(1609,1) in function 'ontimeout'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(458,1) in function 'UpdateState'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(515,1) in function 'Update'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(111,1) in function 'Update'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/update.lua(127,1)
Link to comment
Share on other sites

you should really attach a log since what you post isnt showing where the error happens. you just show that it was caused from that. thats just the error showing an error screen from what caused it.

 

Wait , what? Sorry I didn't understand what you mean , make your sentence more understandable . I'm confused ( SORRY I CAN'T UNDERSTAND ENGLISH PATENTLY  ).  That's the only crash log I know that I should post here.

Link to comment
Share on other sites

attach the full log is what i meant. like instead of adding the last chunk in a spoiler, attach the log in the more reply options so we can fully see all of the log.txt what you posted shows the error it had, but didnt give the information about where it found the error. if you attach it, i can show you exactly where the error happens without any other file. (show you what to look at instead of the bottom).

it should say something about which file the error occurred in, what line, and near what word it had the argument with. if i help you with reading logs, you might not need as much help in future modding :D

Link to comment
Share on other sites

 

Okay , after I put the GLOBAL in , and after I crafted a torch the game crashed again. ANOTHER NEW LOG CRASH AGAIN.

 

...LC/data/../mods/New folder/scripts/prefabs/torch.lua:135: variable 'GLOBAL' is not declared
LUA ERROR stack traceback:
        =[C] in function 'error'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/strict.lua(23,1)
        C:/Games/Dont Starve v1.104670 with DLC/data/../mods/New folder/scripts/prefabs/torch.lua(135,1) in function 'fn'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(126,1)
        =[C] in function 'SpawnPrefab'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/mainfunctions.lua(160,1) in function 'SpawnPrefab'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/components/builder.lua(300,1) in function 'DoBuild'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/actions.lua(637,1) in function 'fn'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/bufferedaction.lua(19,1) in function 'Do'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/entityscript.lua(942,1) in function 'PerformBufferedAction'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraphs/SGwilson.lua(1609,1) in function 'ontimeout'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(458,1) in function 'UpdateState'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(515,1) in function 'Update'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/stategraph.lua(111,1) in function 'Update'
        C:/Games/Dont Starve v1.104670 with DLC/data/scripts/update.lua(127,1)

 

 

Okay so you're overwriting the torch.lua file in order to make your mod. This means you shouldn't need to make TUNING.COLDTORCH_FUEL a global variable however, you need to make sure it's not nil.

 

A nil value when comparing it to a number will always result in an error. Try something like:

if not TUNING.COLDTORCH_FUEL == nil thenend

If it is nil, the be sure to set it properly.

 

Edit: Properly addressed the if statement to be correct.

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...