Jump to content

Recommended Posts

I created a character mod, and am now trying to add a custom weapon, but I must be doing SOMETHING wrong, because the game crashes when I try to activate it. It was originally going to go with my character mod, but I had to separate the two in order to try and figure out what the problem was. I've tried everything I can think of, but it's still having issues. I've even copied and pasted code and used templates for making it, but something is still amiss. I'm pretty sure it's not the coding but I'll include it here. Any help would be appreciated!

modmain.lua

modinfo.lua

kurikara.lua

First, what is this for (modmain)?

local function load() --can be removed IMO
	local kurikara = GLOBAL.Recipe( "kurikara", {Ingredient("flint", 1)},  RECIPETABS.WAR, {SCIENCE=1} )
	kurikara.atlas = "images/inventoryimages/kurikara.xml"   
	   
	TheSim:LoadPrefabs({"kurikara"})--can be removed IMO
	local kurikara = GLOBAL.GetRecipe("kurikara")--can be removed IMO
end--can be removed IMO
	   
AddGamePostInit(load)--can be removed IMO

Use the log to find the issue.

 

1 hour ago, Mobbstar said:

First, what is this for (modmain)?


local function load() --can be removed IMO
	local kurikara = GLOBAL.Recipe( "kurikara", {Ingredient("flint", 1)},  RECIPETABS.WAR, {SCIENCE=1} )
	kurikara.atlas = "images/inventoryimages/kurikara.xml"   
	   
	TheSim:LoadPrefabs({"kurikara"})--can be removed IMO
	local kurikara = GLOBAL.GetRecipe("kurikara")--can be removed IMO
end--can be removed IMO
	   
AddGamePostInit(load)--can be removed IMO

Use the log to find the issue.

 

This was part of another mod I copy and pasted from, it allows the item to be crafted, since I couldn't figure out how to make my character start with it. I actually solved the issue a little while ago, after almost a week of trying. It turned out there was something wrong with the build files, so the only issue I'm having now is trying to get the item to not be invisible when I equip it.

 

5 minutes ago, DragonAvenger24 said:

This was part of another mod I copy and pasted from, it allows the item to be crafted, since I couldn't figure out how to make my character start with it. I actually solved the issue a little while ago, after almost a week of trying. It turned out there was something wrong with the build files, so the only issue I'm having now is trying to get the item to not be invisible when I equip it.

Maybe this helps: link

17 hours ago, Mobbstar said:

Maybe this helps: link

I checked it out, but I think I don't quite know where to put everything (Spriter files, images, etc.). Do you have an example of this I could go off of? I'm still super new to this.

Kurikara.zip

9 hours ago, pickleplayer said:

Maybe this will help?

(Edit: wait here's a better one)

 

 

This did help me out quite a bit, I followed the sample download at the beginning and put all my files where they were in the example. I changed up a bunch of things, but it's still invisible in my hand, and I'm really not sure why. I even made sure it wasn't a size issue and scaled it up in the image file, but to no avail. I have a newer version of it here:

Kurikara.zip

36 minutes ago, DragonAvenger24 said:

This did help me out quite a bit, I followed the sample download at the beginning and put all my files where they were in the example. I changed up a bunch of things, but it's still invisible in my hand, and I'm really not sure why. I even made sure it wasn't a size issue and scaled it up in the image file, but to no avail. I have a newer version of it here:

Kurikara.zip

usually if it is invisible when equipped it is because of a problem with the anim files.

Having not worked with a weapon/item myself I can't offer anything more than that.

Sometimes there may be an error in the log, for example if the texture is not loaded by the code. Have you checked there?

Also, I suggest you use the Autocompiler from the Don't Starve Mod Tools on Steam to compile the images and animations. This removes a potential issue with image clipping, and is done automatically upon game launch.

 

Firstly, the assets in 'modmain.lua' are not loaded correctly. Try this:

Assets = {
	Asset("ATLAS", "images/inventoryimages/kurikara.xml"),
	Asset("IMAGE", "images/inventoryimages/kurikara.tex")
}

Second, there is no need to encase the recipe in a 'load' function, and 'AddGamePostInit' it. The code can be run directly from 'modmain.lua'.

Third, it is good form to use the global reference tables provided in 'constants.lua', 'strings.lua', and 'tuning.lua' (eg. 'GLOBAL.TECH.NONE' instead of '{SCIENCE = 0}').

Fourth, there is no need to manually call 'TheSim:LoadPrefabs'. The prefab will be automatically loaded by having it's file in the 'PrefabFiles' list. There is also no reason to assign the recipe to a local variable again, as you already have it assigned to the same variable, and you only need that so you can set the atlas.

Fifth, the 'torchfire.lua' file will override the default one, altering all torch fires. Is this your intention?

Finally, the final line of 'kurikara.lua' should include the 'prefabs' table, to insure that 'torchfire.lua' is loaded before the Kurikara. Because this is a mod, this is unnecessary, but that is why the 'prefabs' table exists.

On 1/20/2016 at 3:57 AM, Arkathorn said:

Sometimes there may be an error in the log, for example if the texture is not loaded by the code. Have you checked there?

Also, I suggest you use the Autocompiler from the Don't Starve Mod Tools on Steam to compile the images and animations. This removes a potential issue with image clipping, and is done automatically upon game launch.

 

Firstly, the assets in 'modmain.lua' are not loaded correctly. Try this:


Assets = {
	Asset("ATLAS", "images/inventoryimages/kurikara.xml"),
	Asset("IMAGE", "images/inventoryimages/kurikara.tex")
}

Second, there is no need to encase the recipe in a 'load' function, and 'AddGamePostInit' it. The code can be run directly from 'modmain.lua'.

Third, it is good form to use the global reference tables provided in 'constants.lua', 'strings.lua', and 'tuning.lua' (eg. 'GLOBAL.TECH.NONE' instead of '{SCIENCE = 0}').

Fourth, there is no need to manually call 'TheSim:LoadPrefabs'. The prefab will be automatically loaded by having it's file in the 'PrefabFiles' list. There is also no reason to assign the recipe to a local variable again, as you already have it assigned to the same variable, and you only need that so you can set the atlas.

Fifth, the 'torchfire.lua' file will override the default one, altering all torch fires. Is this your intention?

Finally, the final line of 'kurikara.lua' should include the 'prefabs' table, to insure that 'torchfire.lua' is loaded before the Kurikara. Because this is a mod, this is unnecessary, but that is why the 'prefabs' table exists.

Alright, well I fixed a couple things and checked the log like you asked. I DID find an error which seems to be linked to the swap animations, "Could not find anim build swap_kurikara". But I'm not entirely sure what needs to be done to fix this issue, since I seem to have all the files for it and followed the guide very closely.

Edit:

I found out what the problem was, I guess I had a copy of the swap_kurikara.anim in another mod I was working on and that was causing conflicts with the updated version I had created. Thanks everybody for all your help!

 

Edited by DragonAvenger24
Fixed It!
On 1/20/2016 at 3:57 AM, Arkathorn said:

Sometimes there may be an error in the log, for example if the texture is not loaded by the code. Have you checked there?

Also, I suggest you use the Autocompiler from the Don't Starve Mod Tools on Steam to compile the images and animations. This removes a potential issue with image clipping, and is done automatically upon game launch.

 

Firstly, the assets in 'modmain.lua' are not loaded correctly. Try this:


Assets = {
	Asset("ATLAS", "images/inventoryimages/kurikara.xml"),
	Asset("IMAGE", "images/inventoryimages/kurikara.tex")
}

Second, there is no need to encase the recipe in a 'load' function, and 'AddGamePostInit' it. The code can be run directly from 'modmain.lua'.

Third, it is good form to use the global reference tables provided in 'constants.lua', 'strings.lua', and 'tuning.lua' (eg. 'GLOBAL.TECH.NONE' instead of '{SCIENCE = 0}').

Fourth, there is no need to manually call 'TheSim:LoadPrefabs'. The prefab will be automatically loaded by having it's file in the 'PrefabFiles' list. There is also no reason to assign the recipe to a local variable again, as you already have it assigned to the same variable, and you only need that so you can set the atlas.

Fifth, the 'torchfire.lua' file will override the default one, altering all torch fires. Is this your intention?

Finally, the final line of 'kurikara.lua' should include the 'prefabs' table, to insure that 'torchfire.lua' is loaded before the Kurikara. Because this is a mod, this is unnecessary, but that is why the 'prefabs' table exists.

Do you know how I could apply this affect to my weapon? I want it to have a flame on it that's blue but I can't get it to be a separate prefab without it changing all the torches in the game.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...