Jump to content

How to add a custom recipe to an existing item only for a specific character?


Recommended Posts

Inside modmain.lua goes

local prefabname = Ingredient( "prefabname", 1 )
prefabname.atlas = "images/inventoryimages/prefabname.xml"
local prefabname_recipe = AddRecipe("prefabname", {Ingredient("log", 1), Ingredient("rope", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "yourcharactername", "images/inventoryimages/prefabname.xml")

Swap "prefabname" with the name of item.

Rememer to post this:

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH 

above.

 

Also add

inst:AddTag("yourcharactername")

inside of yourcharacter.lua (sripts->prefabs->...) inside common_postinit.

Cheers!

 

Edited by Yakuzashi
  • Like 2
Link to comment
Share on other sites

12 hours ago, Yakuzashi said:

Inside modmain.lua goes


local prefabname = Ingredient( "prefabname", 1 )
prefabname.atlas = "images/inventoryimages/prefabname.xml"
local prefabname_recipe = AddRecipe("prefabname", {Ingredient("log", 1), Ingredient("rope", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "yourcharactername", "images/inventoryimages/prefabname.xml")

Swap "prefabname" with the name of item.

Rememer to post this:


local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local Ingredient = GLOBAL.Ingredient
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH 

above.

 

Also add


inst:AddTag("yourcharactername")

inside of yourcharacter.lua (sripts->prefabs->...) inside common_postinit.

Cheers!

 

It seems that the caused my game to crash. I did everything you said, but I may have done something wrong. I have included my modmain and character prefab folder to this comment. wayne.lua

modmain.lua

Edited by Earthyburt
Link to comment
Share on other sites

2 hours ago, Earthyburt said:

It seems that the caused my game to crash. I did everything you said, but I may have done something wrong. I have included my modmain and character prefab folder to this comment. wayne.lua

modmain.lua 3.01 kB · 0 downloads

I had a look at the crash looks; here is where things went wrong; tried to add the xml file it asked for, but nothing worked

 

[00:00:55]: MOD ERROR: Wayne_the_Experiment (Wayne the Experiment): Mod: Wayne_the_Experiment (Wayne the Experiment)	
[00:00:56]: Event data unavailable: lavaarena_event_server/lavaarena_achievement_quest_defs
[00:00:56]: [string "scripts/util.lua"]:562: Could not find an asset matching images/inventoryimages/nightmarefuel.xml in any of the search paths.
LUA ERROR stack traceback:
        =[C] in function 'assert'
        scripts/util.lua(562,1) in function 'resolvefilepath'
        scripts/recipe.lua(100,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'Recipe'
        scripts/modutil.lua(476,1) in function 'AddRecipe'
        ../mods/Wayne_the_Experiment/modmain.lua(68,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(723,1) in function 'RunInEnvironment'
        scripts/mods.lua(529,1) in function 'InitializeModMain'
        scripts/mods.lua(503,1) in function 'LoadMods'
        scripts/main.lua(318,1) in function 'ModSafeStartup'
        scripts/main.lua(394,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(26,1) in function 'SavePersistentString'
        scripts/modindex.lua(118,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(105,1) in function 'BeginStartupSequence'
        scripts/main.lua(393,1) in function 'callback'
        scripts/modindex.lua(659,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(633,1) in function 'Load'
        scripts/main.lua(392,1) in main chunk
[00:00:56]: [string "scripts/mainfunctions.lua"]:1118: variable 'global_error_widget' is not declared
LUA ERROR stack traceback:
        =[C] in function 'error'
        scripts/strict.lua(23,1)
        scripts/mainfunctions.lua(1118,1)
        =[C] in function 'GetPersistentString'
        scripts/quagmire_recipebook.lua(54,1) in function 'Load'
        scripts/main.lua(336,1) in function 'ModSafeStartup'
        scripts/main.lua(394,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(26,1) in function 'SavePersistentString'
        scripts/modindex.lua(118,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(105,1) in function 'BeginStartupSequence'
        scripts/main.lua(393,1) in function 'callback'
        scripts/modindex.lua(659,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(633,1) in function 'Load'
        scripts/main.lua(392,1) in main chunk
[00:00:56]: Faild to load the cookbook!	false	[string "scripts/json.lua"]:450: Failed to load string [ return "filters"] in JSON4Lua.decode_scanString at position 2 : 11	
[00:00:56]: DoLuaFile Error: (null)
[00:00:56]: LuaError but no error string
[00:00:56]: Error loading main.lua
[00:00:56]: Failed mSimulation->Reset()
[00:00:56]: Error during game restart!
[00:00:57]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:57]: Collecting garbage...
[00:00:57]: lua_gc took 0.05 seconds
[00:00:57]: ~ShardLuaProxy()
[00:00:57]: ~cEventLeaderboardProxy()
[00:00:57]: ~ItemServerLuaProxy()
[00:00:57]: ~InventoryLuaProxy()
[00:00:57]: ~NetworkLuaProxy()
[00:00:57]: ~SimLuaProxy()
[00:00:57]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:57]: lua_close took 0.02 seconds
[00:00:57]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:00:57]: [Steam] Auth ticket cancelled
[00:00:58]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:00:58]: CurlRequestManager::ClientThread::Main() complete
[00:00:58]: HttpClient2 discarded 0 callbacks.
[00:00:58]: Shutting down

 

Link to comment
Share on other sites

You need to create folder called "inventoryimages" inside of "images" and you need to use 64x64x24 .png as a base. Then into inventoryimages goes: png + tex + xml.

You might need to convert .png file into .tex with TexTools.

Then inside modmain.lua ->Assets ={}

	Asset("ATLAS", "images/inventoryimages/prefabname.xml"),
    Asset("IMAGE", "images/inventoryimages/prefabname.tex"), 

 

 

prefabname.png

prefabname.xml

Edited by Yakuzashi
  • Like 1
Link to comment
Share on other sites

Quote

I think that it should covert when you compile everhthing, not sure tho

Sometime it does and sometime not. I want to be sure everytime, so I do it myself.

The 64x64x24 it's for item image on inventory bar. When I have tried to change dimensions, everything went bad. It was long time ago, and now I am not sure about necessity of this format.

  • Thanks 1
Link to comment
Share on other sites

 

I did put in the image atlas files, but I just found out the crash was from a typo error. However, now it just displays a campfire instead of nightmare fuel. I think this is an issue with the image size, 64 x 64, instead of 64 x 64 x 24, but I do not know how to set the image that way

Edited by Earthyburt
Link to comment
Share on other sites

I don't play DST thus I haven't know that nightmarefuel has one recipe already. Basically you don't need to add and show direction of inventory image inside of modmain.lua anymore. I just modified few lines inside modmain. I would also reccomend to delete nightmarefuel.png etc. from inventoryimages folder in order to avoid errors.modmain.lua Cheers!

Edited by Yakuzashi
  • Thanks 1
Link to comment
Share on other sites

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
 Share

×
  • Create New...