Jump to content

Recommended Posts

Hello,

 

I have  added a recipe to an item I like on the workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=380122571&searchtext=reaper. But I wanted to add to it so that I can use it. I have gotten some help from the other dont starve forum, but I realize that that was the wrong forum, and they helped me get the recipe working.

 

However, it does not work with DST, it has a few bugs for non-host players: animations do not work, they sometimes can not pick grass ect, and sometimes they have all of the recipes unlocked. 

 

local require = GLOBAL.require
local Ingredient = GLOBAL.Ingredient
local STRINGS = GLOBAL.STRINGS
local ACTIONS = GLOBAL.ACTIONS
local Action = GLOBAL.Action
local resolvefilepath = GLOBAL.resolvefilepath
local RECIPETABS = GLOBAL.RECIPETABS
 
PrefabFiles = {
"reaper",
"scythe",
}
 
Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/reaper.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/reaper.xml" ),
 
    Asset( "IMAGE", "images/selectscreen_portraits/reaper.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/reaper.xml" ),
 
    Asset( "IMAGE", "bigportraits/reaper.tex" ),
    Asset( "ATLAS", "bigportraits/reaper.xml" ),
 
Asset( "IMAGE", "images/map_icons/reaper.tex" ),
Asset( "ATLAS", "images/map_icons/reaper.xml" ),
 
Asset( "IMAGE", "images/avatars/avatar_reaper.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_reaper.xml" ),
 
Asset( "IMAGE", "images/avatars/avatar_ghost_reaper.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_reaper.xml" ),
 
Asset("ANIM", "anim/scythe.zip"),
Asset("ANIM", "anim/swap_scythe.zip"),
Asset("IMAGE", "images/inventoryimages/scythe.tex"),
Asset("ATLAS", "images/inventoryimages/scythe.xml"),
}
 
-- The character select screen lines
STRINGS.CHARACTER_TITLES.reaper = "Traveller of Lordran"
STRINGS.CHARACTER_NAMES.reaper = "DreadScythe"
STRINGS.CHARACTER_DESCRIPTIONS.reaper = "*Weapon with a long curved blade \n*Draws power from the night "
STRINGS.CHARACTER_QUOTES.reaper = "\"I WILL REND YOUR SOUL.\""
 
-- Custom speech strings
STRINGS.CHARACTERS.REAPER = require "speech_reaper"
 
-- The character's name as appears in-game 
STRINGS.NAMES.REAPER = "DreadScythe"
 
STRINGS.NAMES.SCYTHE = "Great Scythe"
STRINGS.RECIPE_DESC.SCYTHE = "The magnificent sharp curved blade instills fear in opponents."
STRINGS.CHARACTERS.GENERIC.DESCRIBE.SCYTHE = "FEEL MY POWER!"
 
-- The default responses of examining the character
STRINGS.CHARACTERS.GENERIC.DESCRIBE.REAPER = 
{
GENERIC = "Looks strangely",
ATTACKER = "Looks suspicious...",
MURDERER = "Murderer!",
REVIVER = "DreadScythe, friend of ghosts.",
GHOST = "YOU FOOL",
}
 
-- Let the game know character is male, female, or robot
table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "reaper")
 
AddMinimapAtlas("images/map_icons/reaper.xml")
AddModCharacter("reaper")
 
 
AddPrefabPostInit("reaper",function(inst)
                        local scythe_recipe = Recipe("scythe", {Ingredient("petals", 1)}, GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.NONE)
                        scythe_recipe.sortkey = -73
                        scythe_recipe.atlas="images/inventoryimages/scythe.xml" 
                        GLOBAL.STRINGS.RECIPE_DESC.scythe= "Great Scythe"

end)

 

 

local assets=
{
Asset("ANIM", "anim/scythe.zip"),
    Asset("ANIM", "anim/swap_scythe.zip"), 
 
    Asset("ATLAS", "images/inventoryimages/scythe.xml"),
    Asset("IMAGE", "images/inventoryimages/scythe.tex")
}
 
local function OnUsed (inst)
inst:Remove()
end
 
    local function OnEquip(inst, owner)
        owner.AnimState:OverrideSymbol("swap_object", "swap_scythe", "scythe")
        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()
 
inst.entity:AddTransform()
inst.entity:AddAnimState()
    inst.entity:AddLight()
    inst.entity:AddNetwork()
 
    MakeInventoryPhysics(inst)
 
 
    inst.AnimState:SetBank("scythe")
    inst.AnimState:SetBuild("scythe")
    inst.AnimState:PlayAnimation("idle")
 
   inst:AddTag("sharp")
 
    if not TheWorld.ismastersim then
        return inst
    end
 
    inst.entity:SetPristine()
 
    inst:AddComponent("inspectable")
 
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages/scythe.xml"
 
inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
 
inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*2)
 
inst:AddComponent("finiteuses")
inst.components.finiteuses:SetMaxUses(200)
inst.components.finiteuses:SetUses(200)
inst.components.finiteuses:SetOnFinished(OnUsed)
 
 
    MakeHauntableLaunch(inst)
 
return inst
end
 
 

return Prefab( "common/inventory/scythe", fn, assets ) 

Link to comment
https://forums.kleientertainment.com/forums/topic/53464-help-with-adding-recipe/
Share on other sites

Take it out the AddPrefabPostInit.

GLOBAL.STRINGS.RECIPE_DESC.SCYTHE = "Great Scythe"local myrecipe = AddRecipe("scythe", {Ingredient("petals", 1)}, GLOBAL.TECH.NONE, nil, nil, nil, nil, nil, nil,"images/inventoryimages/scythe.xml", "scythe.tex")myrecipe.sortkey = -73

I had an issue:

 

[00:00:23]: [string "scripts/recipe.lua"]:32: attempt to index field 'level' (a number value)
LUA ERROR stack traceback:
        scripts/recipe.lua(32,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'Recipe'
        scripts/modutil.lua(359,1) in function 'AddRecipe'
        ../mods/workshop-380122571/modmain.lua(73,1) in main chunk
        =[C] in function 'xpcall'
        scripts/util.lua(548,1) in function 'RunInEnvironment'
        scripts/mods.lua(382,1) in function 'InitializeModMain'
        scripts/mods.lua(363,1) in function 'LoadMods'
        scripts/main.lua(246,1) in function 'ModSafeStartup'
        scripts/main.lua(294,1)
        =[C] in function 'SetPersistentString'
        scripts/mainfunctions.lua(25,1) in function 'SavePersistentString'
        scripts/modindex.lua(82,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(69,1) in function 'BeginStartupSequence'
        scripts/main.lua(293,1) in function 'callback'
        scripts/modindex.lua(475,1)
        =[C] in function 'GetPersistentString'
        scripts/modindex.lua(455,1) in function 'Load'
        scripts/main.lua(292,1) in main chunk
[00:00:23]: Error error! We tried displaying an error but TheFrontEnd isn't ready yet...
[00:00:23]: LOADING LUA SUCCESS
[00:00:23]: PlayerDeaths loaded morgue 4910
[00:00:23]: loaded profile
[00:00:23]: bloom_enabled true
[00:00:23]: loaded saveindex
[00:00:23]: OnFilesLoaded()
[00:00:23]: OnUpdatePurchaseStateComplete
[00:00:23]: Unload BE
[00:00:23]: Unload BE done
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP) Registering prefabs
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP)  Registering prefab file: prefabs/reaper
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP)    reaper
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP)  Registering prefab file: prefabs/scythe
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP)    scythe
[00:00:24]: Mod: workshop-380122571 ((DST) Reaper - WIP)  Registering default mod prefab
[00:00:24]: Load FE
[00:00:25]: Load FE: done
[00:00:25]: platform_motd table: 13A34DF0
[00:00:25]: SimLuaProxy::QueryServer()
[00:00:25]: SimLuaProxy::QueryServer()
[00:00:25]: SimLuaProxy::QueryServer()
[00:00:25]: Disabling workshop-380122571 ((DST) Reaper - WIP) because it had an error.
[00:00:25]: SCRIPT ERROR! Showing error screen
[00:00:25]: ModIndex: Load sequence finished successfully.
[00:00:25]: Reset() returning
[00:00:25]: QueryServerComplete no callback
[00:00:25]: QueryServerComplete no callback
[00:00:25]: platform_motd table: 0BFE2FD0
[00:00:25]: Stale Component Reference: GUID 100025, scripts/widgets/text.lua:55
[00:00:25]: Stale Component Reference: GUID 100026, scripts/widgets/text.lua:55
[00:00:25]: Stale Component Reference: GUID 100037, scripts/widgets/text.lua:55
[00:00:25]: Stale Component Reference: GUID 100037, scripts/widgets/text.lua:25
[00:00:54]: Force aborting...
 

 

local require = GLOBAL.require
local Ingredient = GLOBAL.Ingredient
local STRINGS = GLOBAL.STRINGS
local ACTIONS = GLOBAL.ACTIONS
local Action = GLOBAL.Action
local resolvefilepath = GLOBAL.resolvefilepath
local RECIPETABS = GLOBAL.RECIPETABS
 
PrefabFiles = {
"reaper",
"scythe",
}
 
Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/reaper.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/reaper.xml" ),
 
    Asset( "IMAGE", "images/selectscreen_portraits/reaper.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/reaper.xml" ),
 
    Asset( "IMAGE", "bigportraits/reaper.tex" ),
    Asset( "ATLAS", "bigportraits/reaper.xml" ),
 
Asset( "IMAGE", "images/map_icons/reaper.tex" ),
Asset( "ATLAS", "images/map_icons/reaper.xml" ),
 
Asset( "IMAGE", "images/avatars/avatar_reaper.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_reaper.xml" ),
 
Asset( "IMAGE", "images/avatars/avatar_ghost_reaper.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_reaper.xml" ),
 
Asset("ANIM", "anim/scythe.zip"),
Asset("ANIM", "anim/swap_scythe.zip"),
Asset("IMAGE", "images/inventoryimages/scythe.tex"),
Asset("ATLAS", "images/inventoryimages/scythe.xml"),
}
 
-- The character select screen lines
STRINGS.CHARACTER_TITLES.reaper = "Traveller of Lordran"
STRINGS.CHARACTER_NAMES.reaper = "DreadScythe"
STRINGS.CHARACTER_DESCRIPTIONS.reaper = "*Weapon with a long curved blade \n*Draws power from the night "
STRINGS.CHARACTER_QUOTES.reaper = "\"I WILL REND YOUR SOUL.\""
 
-- Custom speech strings
STRINGS.CHARACTERS.REAPER = require "speech_reaper"
 
-- The character's name as appears in-game 
STRINGS.NAMES.REAPER = "DreadScythe"
 
STRINGS.NAMES.SCYTHE = "Great Scythe"
STRINGS.RECIPE_DESC.SCYTHE = "The magnificent sharp curved blade instills fear in opponents."
STRINGS.CHARACTERS.GENERIC.DESCRIBE.SCYTHE = "FEEL MY POWER!"
 
-- The default responses of examining the character
STRINGS.CHARACTERS.GENERIC.DESCRIBE.REAPER = 
{
GENERIC = "Looks strangely",
ATTACKER = "Looks suspicious...",
MURDERER = "Murderer!",
REVIVER = "DreadScythe, friend of ghosts.",
GHOST = "YOU FOOL",
}
 
-- Let the game know character is male, female, or robot
table.insert(GLOBAL.CHARACTER_GENDERS.MALE, "reaper")
 
AddMinimapAtlas("images/map_icons/reaper.xml")
AddModCharacter("reaper")
 
GLOBAL.STRINGS.RECIPE_DESC.SCYTHE = "Great Scythe"
 
local myrecipe = AddRecipe("scythe", 
{Ingredient("petals", 1)}, 
GLOBAL.TECH.NONE, 
nil, nil, nil, nil, nil, nil,
"images/inventoryimages/scythe.xml", "scythe.tex")
 
myrecipe.sortkey = -73
 
-- AddPrefabPostInit("reaper",function(inst)
                        -- local scythe_recipe = Recipe("scythe", {Ingredient("petals", 1)}, GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.NONE)
                        -- scythe_recipe.sortkey = -73
                        -- scythe_recipe.atlas="images/inventoryimages/scythe.xml" 
                        -- GLOBAL.STRINGS.RECIPE_DESC.scythe= "Great Scythe"

-- end)

 

It is giving this crash when I launch the game world

 

[00:00:38]: SCRIPT ERROR! Showing error screen
[00:00:38]: WARNING! Could not find region 'images/inventoryimages/scythe.xml' from atlas 'images/inventoryimages.xml'. Is the region specified in the atlas?
[00:00:38]: Looking for default texture '(null)' from atlas 'images/inventoryimages.xml'.
[00:00:38]: images/inventoryimages.xml
LUA ERROR stack traceback:
        scripts/widgets/image.lua(30,1) in function 'SetTexture'
        scripts/widgets/recipetile.lua(25,1) in function 'SetRecipe'
        scripts/widgets/craftslot.lua(124,1) in function 'Refresh'
        scripts/widgets/craftslot.lua(169,1) in function 'SetRecipe'
        scripts/widgets/crafting.lua(155,1) in function 'UpdateRecipes'
        scripts/widgets/crafting.lua(36,1) in function '_ctor'
        scripts/widgets/mousecrafting.lua(15,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'MouseCrafting'
        scripts/widgets/crafttabs.lua(50,1) in function '_ctor'
        scripts/class.lua(181,1) in function 'CraftTabs'
...
        scripts/screens/playerhud.lua(197,1) in function 'SetMainCharacter'
        scripts/prefabs/player_common.lua(328,1) in function 'ActivateHUD'
        scripts/prefabs/player_common.lua(514,1) in function 'fn'
        scripts/entityscript.lua(930,1) in function 'PushEvent'
        scripts/mainfunctions.lua(284,1)
        =[C] in function 'SendSpawnRequestToServer'
        scripts/mainfunctions.lua(1168,1) in function 'cb'
        scripts/frontend.lua(453,1) in function 'DoFadingUpdate'
        scripts/frontend.lua(505,1) in function 'Update'
        scripts/update.lua(93,1)

I downloaded your workshop mod.

 

I added this at the end:

local myrecipe = AddRecipe("scythe", {Ingredient("petals", 1)}, GLOBAL.RECIPETABS.WAR, GLOBAL.TECH.NONE, nil, nil, nil, nil, nil,"images/inventoryimages/scythe.xml", "scythe.tex")myrecipe.sortkey = -73

and it worked.

 

If you have issues, zip the mod and post it here.

I think it works now, I got everything that I changed back in after cleaning it. The problem was another mod, but it was a modified version anyway and the original works so I don't really care if it isn't compatible. I will play test it and then I was thinking I might want to add something to make the scythe weaker for the first season. But I want to play with the changes to see if that is needed, thanks for the help DarkZero!

It is working for me, but I can't get it to work for the people who join my game. Right now they can't move at all when they join. I have tried uploading it to the workshop hoping that it would work if they are downloading the same version as me. But it doesn't show up in my mod list/ isn't downloading when I am subscribed to it.

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