Jump to content

[Support] Game crash? Post here for help


Recommended Posts

@bigpak, The code is 31 lines lone and your error says line 3986-3989. Are you sure that's the right file?

 

Edit: But for the file you provided, you're missing an "end" to the "trade_fn" function at line 25-26.

 

Fixed code.

--Milkablefunction make_milkable(inst)	inst:AddComponent("trader")	inst.components.trader:SetAcceptTest(trade_test)	inst.components.trader.onaccept = trade_fn	inst.components.trader:Enable()endAddPrefabPostInit("beefalo", make_milkable)--Milkable--Milkable part 2function trade_test(inst, giver, item)	if inst.components.sleeper:IsAsleep() then		return false	elseif item.components.tradable and item:HasTag("MILKBUCKET") then		return true	else		return false	endendfunction trade_fn(inst, giver, item)	if giver and giver.components.inventory then		giver.components.inventory:GiveItem("red_cap")	endendfunction milktag(inst)	inst:AddTag("MILKBUCKET")end

Edit 2: I just realized why you gave only that portion, haha.

 

Link to comment
Share on other sites

@bigpak It's usually ideal to keep the line numbers same when reporting a bug. Otherwise, unless the log is specific about the function names, variables, etc, I'd have to figure out which line it's on by looking through the whole code myself.

In this case, it wasn't an issue because it was a simple problem which my editor picked up right away.

 

And you're welcome! Don't worry, it happens, haha.

Link to comment
Share on other sites

@bigpak

 

Relevant parts of your code,

-- Sets self.test in trader componentinst.components.trader:SetAcceptTest(trade_test)-- ...-- Called in trader component through CanAccept function, due to being set abovefunction trade_test(inst, giver, item)

In the trader component,

function Trader:CanAccept( item )    return self.enabled and (not self.test or self.test(self.inst, item))end

Only two parameters are passed to your test function; self.inst and item in that order.

self.inst refers to the person whom the item is given to.

item refers to, well the item being traded.

 

Your function is accepting 3 parameters, the last one will always be nil.

A "giver" parameter is not passed in. Remove that one, making it receive a total of two parameters (inst and item).

Link to comment
Share on other sites

Relevant error message,

inventory.lua:459: attempt to index field 'components' (a nil value)

In the stack trace, you can see it occurred from warhammer.lua(37,1), which called the GiveItem function,

C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/components/inventory.lua(459,1) in function 'GiveItem'C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/../mods/All In One/scripts/prefabs/warhammer.lua(37,1) in function 'returningredients'

The GiveItem function function takes in an instance of an item as a parameter, not the string name of the item.

(This is what the GiveItem fn looks like)

Inventory:GiveItem( inst, slot, screen_src_pos, skipsound )

You must either create a new instance of the item and pass that in, or retrieve the instance from somewhere that it already exists (a chest or player inventory).

I'm assuming the general idea in your code was to create a new instance at this point. Use the SpawnPrefab function to create a new instance of the prefab using a string name.

GetPlayer().components.inventory:GiveItem(SpawnPrefab(ingredient)) 

-

 

 

There's another issue on the log too, probably from another part of the code.

WARNING! Could not find region 'aoe_spear.tex' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas?images/inventoryimages.xml

Make sure aoe_spear.tex is properly listed in images/inventoryimages.xml.

 

Link to comment
Share on other sites

@bigpak

 

Hmm. Not sure what's causing it. Use this and show me the log.

local function returningredients(inst)    for k,ingredient in pairs(ingredients) do        local item = SpawnPrefab(ingredient)        print("ing", ingredient)        print("item", item)        print("itempref", item.prefab)        GetPlayer().components.inventory:GiveItem()    endend

Don't worry bout it, everyone needs help sometimes, haha.

 

Edit: Also.. please see my previous post edit. I meant to say change it to "ingredient".

 

Edit 2: Nevermind, I figured out what's wrong. I meant that you wrote ingredients with an "s". It should be without the "s", just ingredient. Do not put them in quotes.

Link to comment
Share on other sites

Hello, thanks for offering help!

 

I have a problem where I have a nil global value when trying to change the damage multiplier for my character mod. I know you talk about it in your post, but I do not know how to change the value, and what to change it to.

 

My line of code is: inst.components.combat.damagemultiplier = 1.5

 

I have it under the modmain.lua

 

My crash log is attached. My character's name is george.

 

Thanks again!

log.txt

Link to comment
Share on other sites

@Dwim The inst variable doesn't refer to anything in the modmain file on it's own. Put that line in your character's prefab file, inside the create function "fn".

local fn = function(inst)    -- ...    -- inst refers to the character instance here    -- ...endreturn MakePlayerCharacter("char_prefab", prefabs, assets, fn)
Link to comment
Share on other sites

I copy-pasted the code into the "local fn = function(inst)" section in the prefab file. Yet when i enable the mod, the game freezes. Did I do something wrong?

 

It looks like this: (I apologize for the format my code was put into the post, I have not yet figured this out completely)

local fn = function(inst)		-- choose which sounds this character will play	inst.soundsname = "wilson"	-- Minimap icon	inst.MiniMapEntity:SetIcon( "george.tex" )		local fn = function(inst)    -- ...     -- inst refers to the character instance here     -- ...end return MakePlayerCharacter("char_prefab", prefabs, assets, fn)		-- Stats		inst.components.health:SetMaxHealth(100)	inst.components.hunger:SetMax(150)	inst.components.sanity:SetMax(200)end
Link to comment
Share on other sites

@Dwim Err. I meant move your code from modmain to your character's prefab. The code I posted was just to demonstrate where you would place your code.

local fn = function(inst)         -- choose which sounds this character will play    inst.soundsname = "wilson"     -- Minimap icon    inst.MiniMapEntity:SetIcon( "george.tex" )         -- Stats        inst.components.health:SetMaxHealth(100)    inst.components.hunger:SetMax(150)    inst.components.sanity:SetMax(200)    -- You can use the "inst" variable in this function. It refers to the player's instance.    -- "inst.components" works here because "inst" is not nil (empty).    --- It won't work in modmain because there is no variable called "inst" there (unless you explicitly make one yourself).    -- Therefore, your code should go here    inst.components.combat.damagemultiplier = 1.5end
Link to comment
Share on other sites

Hi, I've been experiencing an issue with my mod. Here's the error:

 

cripts/mods.lua(17,1) error calling LoadPrefabFile in mod wulfric (Wulfric): 
...m/steamapps/common/dont_starve/data/scripts/util.lua:276: Could not find an asset matching anim/swap_devilstaff.zip in any of the search paths.
LUA ERROR stack traceback:
 
Now I know exactly what this means - There's no animation.zip of devilstaff in the animation folder. However, it won't create it even through force compiling, I'm not sure what is wrong with my exported folder for the assets of the devilstaff, but it will not create that folder, or the ground_devilstaff for that matter.
 
Any ideas?
Link to comment
Share on other sites

but it will not create that folder

 

The exported folder?  You need to create that one.  It's where your scml files should reside.  Unless you mean it won't create the anim folder.

 

In any case, if it's just not exporting your animations, this is a problem that I've run across as well.  I never really tracked down the cause of it, because I ended up using a workaround.  I detailed that here: http://forums.kleientertainment.com/topic/50581-not-creating-animations/#entry610269

 

For each of my mods, I create a .bat file that manually compiles the scml using the command in the link.  I like this method because it lets me make tweaks to animations while the game is open (I just need to reload the assets via console).

Link to comment
Share on other sites

Another question (I apologize, this is my very first mod, and I am new to coding.) My game crashes when I enable the mod, and in the log it points out 2 problems: 

 

.../common/dont_starve/data/../mods/George/scripts/prefabs/hunting_dart.lua:5: '}' expected (to close '{' at line 2) near 'Asset'

 

Yet the '{' is closed:

local assets={ Asset("ANIM", "anim/hunting_dart.zip"), Asset("ATLAS", "images/inventoryimages/hunting_dart.xml"), Asset("ANIM", "anim/hunting_dart.zip")}

And:

 

...m/steamapps/common/dont_starve/data/scripts/util.lua:276: Could not find an asset matching anim/swap_hunting_dart.zip in any of the search paths.

 

How do I solve this one?

 

(I will attach the full log, my mod's name is george.)

log.txt

Link to comment
Share on other sites

@Dwim

Put a comma at the end of line 6. I'm not certain if that's the problem, but I faintly remember someone mentioning it's required when writing the assets (maybe cause of the normal bracket ending?).

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

For the second, you're missing the file (or there's something wrong with it). Make sure you have a file called swap_hunting_dart.zip in "YourModFolder/anim/".

Link to comment
Share on other sites

 

Put a comma at the end of line 6. 

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

Lua doesnt store 'nil' entries in tables so having a comma after your last element never hurts.  And always putting a comma means you wont accidentally forget one if you add more elements later on.  There is no other reason for having that final comma other than  "it never breaks, it always works".

Link to comment
Share on other sites

So it is not the missing comma that makes that problem?

 

And for the second one, in the file called "anim" for my mod I have the animation for the character, and the file for its special item. And in the subfolder for my item I have a media file called "anim," and one called "build." Isn't that all I need?

 

And here I will attach hunting_dart.lua. It is the special item for my character mod (feel free to point out any problems you find if you look through it, it is definitely riddled with them.)

hunting_dart.lua

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