Jump to content

DST Character Modding: saving tags and character specific interactions


Recommended Posts

Hi, I'm trying to create a modded character for DTS but I'm stuck.

The idea is a character that starts really weak but with time could craft a series of items that would allow him to thrive. Also he should be able to craft certain foods that when consumed would increase his stats / give him special abilities (I was thinking about giving him special tags)

I already made the functioning character and managed to mod in a custom recipe tab, items and foods. I also managed to have a function running when the food is eaten.

I tried assigning tags when a certain food is eaten and it works, but when I leave and re-enter they're gone.

I was also trying to code in some abilities like Night Vision, Quick picking and others but if they work, it is for every player in the server (I would like them just to work only if the character has a certain tag)

I know I have a lot of questions but what I need an help with is this (keep in mind that I know lua just enough to understand the code and not mess up):

  1. A way to save/store custom assigned tags (from his consumables) and being able to load them when I re-enter the world
  2. A way to save a custom global variable so that I can adjust his stats accordingly (basically if I consume 5 health increase I don't want to use 5 tags but a variable)
  3. How to code in abilities that only work for a character with a certain tag.
  4. How to make faster shovels (I already made faster axes and pickaxes by changing their effectiveness but it doesn't seem to work with shovels)

Could somebody help me? I'm including both the character.lua and the modmain.lua

 

character.lua

Spoiler

local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
}

-- Custom starting inventory
TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.BALTHAZAR = {
	
}

local start_inv = {}
for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
    start_inv[string.lower(k)] = v.BALTHAZAR
end
local prefabs = FlattenTree(start_inv, true)

-- When the character is revived from human
local function onbecamehuman(inst)
	-- Set speed when not a ghost (optional)
	inst.components.locomotor:SetExternalSpeedMultiplier(inst, "balthazar_speed_mod", 2)
end

local function onbecameghost(inst)
	-- Remove speed modifier when becoming a ghost
   inst.components.locomotor:SetExternalSpeedMultiplier(inst, "balthazar_speed_mod", 2)
end

-- When loading or spawning the character
local function onload(inst)
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)
	
    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end

-- local function NightVision(inst)
	-- if not TheWorld.state.isday then
		-- inst.components.playervision:ForceNightVision(true)
        -- inst.components.playervision:SetCustomCCTable(MONSTERVISION_COLOURCUBES)
    -- else
        -- inst.components.playervision:ForceNightVision(false)
        -- inst.components.playervision:SetCustomCCTable(nil)
	-- end
-- end


-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
	-- Minimap icon
	inst.MiniMapEntity:SetIcon( "balthazar.tex" )

	--Custom tag to access Balthazar's unique crafting tab
	inst:AddTag("balthazar_builder")
	
	--gives Night vision
	-- inst:WatchWorldState("startnight", NightVision)
	-- inst:WatchWorldState("startday", NightVision)
	


-- I put this tags here because they are the only one I found on some forum page and I would like to add some of them with consumables, they are here just to easily find them
	--Cut wood fast like woody
	--inst:AddTag("woodcutter")
	
	--inst:AddTag("spiderwhisperer") --This allows access to crafting spider dens & taming spiders.

	-- inst:AddTag("monster")  --Makes it that you take no penalty from eating monster meat, spiders don't aggro but pigs & bunnymen do.

	-- inst:AddTag(UPGRADETYPES.SPIDER.."_upgradeuser") --This allows you to upgrade spider dens with silk.

	-- inst:AddTag("expertchef") --This allows Willow to cook with the lighter.

	-- inst:AddTag("pyromaniac") --This allows Willow to craft Willow's Lighter & Bernie, & some other unique stuff for Willow.

	-- inst:AddTag("insomniac") --This prevents characters from sleeping

	-- inst:AddTag("bookbuilder") --This allows a character to craft books

	-- inst:AddTag("reader") --Reader tag is not really needed for a character to read books, all you need is reader component in masterpostinit

	-- inst:AddTag("ghostlyfriend") --This allows a character to craft Abigail's Flower, I think it also allows for taming Abigail but I haven't tested it yet

	-- inst:AddTag("shadowmagic") --I'm sure this is what allows a character to craft maxwell shadow minions & maybe use them too.

	-- inst:AddTag("dappereffects") --I don't really know what this does but I assume it's for doing unique things for Maxwell?

	-- inst:AddTag("mime") --This makes your character not able to talk.

	-- inst:AddTag("balloonomancer") --This allows your character to use & craft balloons.
	
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
	-- Set starting inventory
    inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
	
	-- choose which sounds this character will play
	inst.soundsname = "woodie"
	-- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
	
	-- Stats	
	inst.components.health:SetMaxHealth(TUNING.BALTHAZAR_BASE_HP)
	inst.components.hunger:SetMax(TUNING.BALTHAZAR_HUNGER)
	inst.components.sanity:SetMax(TUNING.BALTHAZAR_SANITY)
	
	-- Hunger rate
	inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
	inst.components.hunger:SetRate(TUNING.BALTHAZAR_HUNGER_RATE)
	
	-- Damage multiplier
    inst.components.combat.damagemultiplier = (TUNING.BALTHAZAR_DAMAGE)
	
	--This was taken from a spiderman mod. I was trying to get this one too to work after a consumable is used
	-- Health regen
	--inst.components.health:StartRegen(TUNING.SPIDEY_HP_Regen,1)
	
	
	
	-- Quick pickin
	-- local handle = inst.sg.sg.actionhandlers[ACTIONS.HARVEST]
		-- handle.deststate = function(inst) return "doshortaction" end
	-- local handle = inst.sg.sg.actionhandlers[ACTIONS.PICK]
		-- handle.deststate = function(inst) return "doshortaction" end

	inst.OnLoad = onload
    inst.OnNewSpawn = onload
	
end

return MakePlayerCharacter("balthazar", prefabs, assets, common_postinit, master_postinit, prefabs)

  

 

Modmain.lua

Spoiler

PrefabFiles = {
	"balthazar",
	"balthazar_none",
	"wooden_sword",
	"stone_sword",
	"flint_sword",
	"gold_sword",
	"livingwood_sword",
	"nightmare_sword",
	"tentacle_sword",
	"moonstone_sword",
	"marble_sword",
	"red_sword",
	"health_essence",
	"sanity_essence",
	"flint_axe",
	"gold_axe",
	"red_axe",
	"flint_pickaxe",
	"gold_pickaxe",
	"red_pickaxe",
	--"flint_shovel",
	--"gold_shovel",
	--"red_shovel",
	--"candy_health",
}

Assets = {
    Asset( "IMAGE", "images/saveslot_portraits/balthazar.tex" ),
    Asset( "ATLAS", "images/saveslot_portraits/balthazar.xml" ),
	
	Asset( "IMAGE", "images/hud/balthazar_tab.tex" ),
    Asset( "ATLAS", "images/hud/balthazar_tab.xml" ),

    Asset( "IMAGE", "images/selectscreen_portraits/balthazar.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/balthazar.xml" ),
	
    Asset( "IMAGE", "images/selectscreen_portraits/balthazar_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/balthazar_silho.xml" ),

    Asset( "IMAGE", "bigportraits/balthazar.tex" ),
    Asset( "ATLAS", "bigportraits/balthazar.xml" ),
	
	Asset( "IMAGE", "images/map_icons/balthazar.tex" ),
	Asset( "ATLAS", "images/map_icons/balthazar.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_balthazar.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_balthazar.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_ghost_balthazar.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_balthazar.xml" ),
	
	Asset( "IMAGE", "images/avatars/self_inspect_balthazar.tex" ),
    Asset( "ATLAS", "images/avatars/self_inspect_balthazar.xml" ),
	
	Asset( "IMAGE", "images/names_balthazar.tex" ),
    Asset( "ATLAS", "images/names_balthazar.xml" ),
	
	Asset( "IMAGE", "images/names_gold_balthazar.tex" ),
    Asset( "ATLAS", "images/names_gold_balthazar.xml" ),
}

AddMinimapAtlas("images/map_icons/balthazar.xml")

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS

local resolvefilepath = GLOBAL.resolvefilepath

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

Ingredient = GLOBAL.Ingredient
TECH = GLOBAL.TECH


--Importing Mod Configs
---------------------------------------------------------------
TUNING.BALTHAZAR_BASE_HP = GetModConfigData("balthazarbasehp")
TUNING.BALTHAZAR_SANITY = GetModConfigData("balthazarbasesanity")
TUNING.BALTHAZAR_HUNGER = GetModConfigData("balthazarbasehunger")
--TUNING.SPIDEY_HP_Regen = GetModConfigData("spideybasehpregen")
TUNING.BALTHAZAR_DAMAGE = GetModConfigData("balthazardamage")
TUNING.BALTHAZAR_HUNGER_RATE = GetModConfigData("balthazarbasehungerdrains")
TUNING.SWORDS_REACH = GetModConfigData("swordsreach")
TUNING.SWORDS_CAN_CHOP = GetModConfigData("swordcanchop")
TUNING.SWORD_CHOP_EFFECTIVENESS = GetModConfigData("swordchopeffectiveness")
---------------------------------------------------------------

--CUSTOM ITEMS
---------------------------------------------------------------
--Balthazar's Crafting Tab
local balthazar_tab = AddRecipeTab( "Balthazar's Tab", 996, "images/hud/balthazar_tab.xml", "balthazar_tab.tex", "balthazar_builder")

--Items
GLOBAL.STRINGS.NAMES.WOODEN_SWORD = "Wooden Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.WOODEN_SWORD = "A wooden sword, sturdy but not very effective... I definitely should upgrade this"

GLOBAL.STRINGS.NAMES.STONE_SWORD = "Stone Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.STONE_SWORD = "A stone sword, better than the last one but still... I could upgrade this"

GLOBAL.STRINGS.NAMES.FLINT_SWORD = "Flint Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FLINT_SWORD = "A flint sword, similar to the last one but a bit better... maybe I could upgrade this"

GLOBAL.STRINGS.NAMES.GOLD_SWORD = "Gold Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.GOLD_SWORD = "Now we're talking business. A sharp gold sword. Hmm... I could still upgrade this"

GLOBAL.STRINGS.NAMES.LIVINGWOOD_SWORD = "Livingwood Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.LIVINGWOOD_SWORD = "A livingwood sword that pulsates with life. It's cool but I could upgrade this"

GLOBAL.STRINGS.NAMES.NIGHTMARE_SWORD = "Nightmare Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.NIGHTMARE_SWORD = "A nightmare sword, made with the remains of my fears. It's sharp but I could upgrade this"

GLOBAL.STRINGS.NAMES.TENTACLE_SWORD = "Tentacle Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.TENTACLE_SWORD = "A big jump in quality. A tentacle sword, sharp and spikey... It's really good but still I could upgrade this"

GLOBAL.STRINGS.NAMES.MOONSTONE_SWORD = "Moonstone Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MOONSTONE_SWORD = "A moonstone sword, made with rocks that come from the sky. It's crazy sharp but I could upgrade this"

GLOBAL.STRINGS.NAMES.MARBLE_SWORD = "Marble Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.MARBLE_SWORD = "A sword made of the hardest rock, crazy sharp, just looking at it is painfull... but still I could upgrade this"

GLOBAL.STRINGS.NAMES.RED_SWORD = "Red Sword"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.RED_SWORD = "There you are. My red sword, made from the hardest of gems. Hmm... maybe I could... Nah, you're perfect as you are"

GLOBAL.STRINGS.NAMES.HEALTH_ESSENCE = "Health Essence"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.HEALTH_ESSENCE = "Getting this hurt A LOT "

GLOBAL.STRINGS.NAMES.SANITY_ESSENCE = "Sanity Essence"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.SANITY_ESSENCE = "I almost went mad to get this "

GLOBAL.STRINGS.NAMES.FLINT_AXE = "Flint Axe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FLINT_AXE = "A crude and basic axe, but seems durable"

GLOBAL.STRINGS.NAMES.GOLD_AXE = "Gold Axe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.GOLD_AXE = "A golden axe, fancy and durable"

GLOBAL.STRINGS.NAMES.RED_AXE = "Red Gem Axe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.RED_AXE = "An axe made from the hardest of gems"

GLOBAL.STRINGS.NAMES.FLINT_PICKAXE = "Flint Pickaxe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FLINT_PICKAXE = "A crude and basic pickaxe, but seems durable"

GLOBAL.STRINGS.NAMES.GOLD_PICKAXE = "Gold Pickaxe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.GOLD_PICKAXE = "A golden pickaxe, fancy and durable"

GLOBAL.STRINGS.NAMES.RED_PICKAXE = "Red Gem Pickaxe"
GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.RED_PICKAXE = "A pickaxe made from the hardest of gems"

-- GLOBAL.STRINGS.NAMES.FLINT_SHOVEL = "Flint Shovel"
-- GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.FLINT_SHOVEL = "A crude and basic shovel, but seems durable"

-- GLOBAL.STRINGS.NAMES.GOLD_SHOVEL = "Gold Shovel"
-- GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.GOLD_SHOVEL = "A golden shovel, fancy and durable"

-- GLOBAL.STRINGS.NAMES.RED_SHOVEL = "Red Gem Shovel"
-- GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.RED_SHOVEL = "A shovel made from the hardest of gems"


--Recipes

AddRecipe("health_essence", 
{GLOBAL.Ingredient(GLOBAL.CHARACTER_INGREDIENT.HEALTH, 50)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/health_essence.xml", "health_essence.tex" )

AddRecipe("sanity_essence", 
{GLOBAL.Ingredient(GLOBAL.CHARACTER_INGREDIENT.SANITY, 50)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/sanity_essence.xml", "sanity_essence.tex" )

AddRecipe("wooden_sword", 
{GLOBAL.Ingredient("twigs", 1), GLOBAL.Ingredient("boards", 5)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/wooden_sword.xml", "wooden_sword.tex" )

AddRecipe("stone_sword", 
{GLOBAL.Ingredient("wooden_sword", 1, "images/inventoryimages/wooden_sword.xml"), Ingredient("cutstone", 7)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/stone_sword.xml", "stone_sword.tex" )

AddRecipe("flint_sword", 
{GLOBAL.Ingredient("stone_sword", 1, "images/inventoryimages/stone_sword.xml"), Ingredient("flint", 20)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/flint_sword.xml", "flint_sword.tex" )

AddRecipe("gold_sword", 
{GLOBAL.Ingredient("flint_sword", 1, "images/inventoryimages/flint_sword.xml"), Ingredient("goldnugget", 20)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/gold_sword.xml", "gold_sword.tex" )

AddRecipe("livingwood_sword", 
{GLOBAL.Ingredient("gold_sword", 1, "images/inventoryimages/gold_sword.xml"), Ingredient("livinglog", 20)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/livingwood_sword.xml", "livingwood_sword.tex" )

AddRecipe("nightmare_sword", 
{GLOBAL.Ingredient("livingwood_sword", 1, "images/inventoryimages/livingwood_sword.xml"), Ingredient("nightmarefuel", 20)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/nightmare_sword.xml", "nightmare_sword.tex" )

AddRecipe("tentacle_sword", 
{GLOBAL.Ingredient("nightmare_sword", 1, "images/inventoryimages/nightmare_sword.xml"), Ingredient("tentaclespike", 5)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/tentacle_sword.xml", "tentacle_sword.tex" )

AddRecipe("moonstone_sword", 
{GLOBAL.Ingredient("tentacle_sword", 1, "images/inventoryimages/tentacle_sword.xml"), Ingredient("moonrocknugget", 5)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/moonstone_sword.xml", "moonstone_sword.tex" )

AddRecipe("marble_sword", 
{GLOBAL.Ingredient("moonstone_sword", 1, "images/inventoryimages/moonstone_sword.xml"), Ingredient("marble", 10)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/marble_sword.xml", "marble_sword.tex" )

AddRecipe("red_sword", 
{GLOBAL.Ingredient("marble_sword", 1, "images/inventoryimages/marble_sword.xml"), Ingredient("redgem", 5)},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/red_sword.xml", "red_sword.tex" )

AddRecipe("flint_axe", 
{GLOBAL.Ingredient("axe", 4), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/flint_axe.xml", "flint_axe.tex" )

AddRecipe("gold_axe", 
{GLOBAL.Ingredient("goldenaxe", 4), GLOBAL.Ingredient("flint_axe", 1, "images/inventoryimages/flint_axe.xml"), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/gold_axe.xml", "gold_axe.tex" )

AddRecipe("red_axe", 
{GLOBAL.Ingredient("gold_axe", 1, "images/inventoryimages/gold_axe.xml"), GLOBAL.Ingredient("health_essence", 10, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/red_axe.xml", "red_axe.tex" )

AddRecipe("flint_pickaxe", 
{GLOBAL.Ingredient("pickaxe", 4), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/flint_pickaxe.xml", "flint_pickaxe.tex" )

AddRecipe("gold_pickaxe", 
{GLOBAL.Ingredient("goldenpickaxe", 4), GLOBAL.Ingredient("flint_pickaxe", 1, "images/inventoryimages/flint_pickaxe.xml"), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/gold_pickaxe.xml", "gold_pickaxe.tex" )

AddRecipe("red_pickaxe", 
{GLOBAL.Ingredient("gold_pickaxe", 1, "images/inventoryimages/gold_pickaxe.xml"), GLOBAL.Ingredient("health_essence", 10, "images/inventoryimages/health_essence.xml")},
balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
"images/inventoryimages/red_pickaxe.xml", "red_pickaxe.tex" )

-- AddRecipe("flint_shovel", 
-- {GLOBAL.Ingredient("shovel", 4), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
-- balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
-- "images/inventoryimages/flint_shovel.xml", "flint_shovel.tex" )

-- AddRecipe("gold_shovel", 
-- {GLOBAL.Ingredient("goldenshovel", 4), GLOBAL.Ingredient("flint_shovel", 1, "images/inventoryimages/flint_pickaxe.xml"), GLOBAL.Ingredient("health_essence", 1, "images/inventoryimages/health_essence.xml")},
-- balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
-- "images/inventoryimages/gold_shovel.xml", "gold_shovel.tex" )

-- AddRecipe("red_shovel", 
-- {GLOBAL.Ingredient("gold_shovel", 1, "images/inventoryimages/gold_shovel.xml"), GLOBAL.Ingredient("health_essence", 10, "images/inventoryimages/health_essence.xml")},
-- balthazar_tab, TECH.NONE, nil, nil, nil, nil, "balthazar_builder", 
-- "images/inventoryimages/red_shovel.xml", "red_shovel.tex" )

-- Custom Recipe Descriptions
STRINGS.RECIPE_DESC.WOODEN_SWORD = "A basic but sturdy wooden sword"
STRINGS.RECIPE_DESC.STONE_SWORD = "A crude stone sword"
STRINGS.RECIPE_DESC.FLINT_SWORD = "Like the stone sword but improved" 
STRINGS.RECIPE_DESC.GOLD_SWORD = "A proper gold sword" 
STRINGS.RECIPE_DESC.LIVINGWOOD_SWORD = "A sword made from living wood" 
STRINGS.RECIPE_DESC.NIGHTMARE_SWORD = "A sword of my worst fears" 
STRINGS.RECIPE_DESC.TENTACLE_SWORD = "A quick trip in the swamp" 
STRINGS.RECIPE_DESC.MOONSTONE_SWORD = "A sword from the sky" 
STRINGS.RECIPE_DESC.MARBLE_SWORD = "A sword of marble"
STRINGS.RECIPE_DESC.RED_SWORD = "It's so cool!" 
STRINGS.RECIPE_DESC.HEALTH_ESSENCE = "A piece of me"
STRINGS.RECIPE_DESC.SANITY_ESSENCE = "A piece of me"
STRINGS.RECIPE_DESC.FLINT_AXE = "A flint axe"
STRINGS.RECIPE_DESC.GOLD_AXE = "A golden axe"
STRINGS.RECIPE_DESC.RED_AXE = "A redgem axe"
STRINGS.RECIPE_DESC.FLINT_PICKAXE = "A flint pickaxe"
STRINGS.RECIPE_DESC.GOLD_PICKAXE = "A golden pickaxe"
STRINGS.RECIPE_DESC.RED_PICKAXE = "A redgem pickaxe"
-- STRINGS.RECIPE_DESC.FLINT_SHOVEL = "A flint shovel"
-- STRINGS.RECIPE_DESC.GOLD_SHOVEL = "A golden shovel"
-- STRINGS.RECIPE_DESC.RED_SHOVEL = "A redgem shovel"
---------------------------------------------------------------



-- Quick pickin
--local myhandler = GLOBAL.ActionHandler(GLOBAL.ACTIONS.PICK, function(inst, action)
--	if action.target.components.pickable then
--		if action.target.components.pickable.quickpick or inst.prefab == "balthazar_builder" then
--			return "doshortaction"
--		else
--			return "dolongaction"
--		end
--	end
--end)

--AddStategraphActionHandler("wilson", myhandler)



-- The character select screen lines
STRINGS.CHARACTER_TITLES.balthazar = "The Maker"
STRINGS.CHARACTER_NAMES.balthazar = "Balthazar"
STRINGS.CHARACTER_DESCRIPTIONS.balthazar = "He delves into magic and science, can unlock the crafting of almost any item but is very weak (gets better over time)"
STRINGS.CHARACTER_QUOTES.balthazar = "\"What does this do?\""
STRINGS.CHARACTER_SURVIVABILITY.balthazar = "Very Slim"

-- Custom speech strings
STRINGS.CHARACTERS.BALTHAZAR = require "speech_balthazar"

-- The character's name as appears in-game 
STRINGS.NAMES.BALTHAZAR = "Balthazar"
STRINGS.SKIN_NAMES.balthazar_none = "Balthazar"

-- The skins shown in the cycle view window on the character select screen.
-- A good place to see what you can put in here is in skinutils.lua, in the function GetSkinModes
local skin_modes = {
    { 
        type = "ghost_skin",
        anim_bank = "ghost",
        idle_anim = "idle", 
        scale = 0.75, 
        offset = { 0, -25 } 
    },
}

-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.
AddModCharacter("balthazar", "MALE", skin_modes)

 

Thanks!

Link to comment
Share on other sites

From what it looks like, your character can eat a consumable to gain max health and sanity correct? Since I dont actually see the functions that initially apply these effects, I'm unsure if its meant to be a permanent increase to those stats, a temporary boost, or just a jellybean like regen effect. I will try to do my best to answer some of your questions.

1. While I personally would go over to WX or jellybean prefabs to figure out how they handle their regen/maxstat increases, the way DST works, is all tags are reapplied on startup. So if you wanted to save a custom tag that you can add to something after initializing (loading into the game), I would look to create an onsave function that saves whether or not the tag(s) were applied, and then have a check in the onload function that checks the onsave data for these tags, and reapplies them. 

1.5. Also little thing I noticed, the reason health regen isn't working is because you copy pasted the code directly from the spiderman mod, and without the mod applied to the server alongside your character mod, the game has no clue what TUNING.SPIDEY_HP_Regen is, and can't put in a proper value. It would be wise to replace that with a flat number or variable tied to said number, one that doesn't require heading to a file in another mod

2. Saving variables would probably also work using the onsave and onload functions, but like I said, the whole thing would likely be a load easier to just go check out WX's/the jellybean prefabs.

3. In simple terms, a tag is a label that you can apply to almost any entity to make it recognizable to certain code. Just doing inst.AddTag("yourtagnamehere") is enough to create a tag. By creating a custom tag and applying it only to your character, you can make character specific actions can only be performed by those with the tag. Even an if statement would suffice for checking if an entity has a specific tag before performing the action.

4. Aren't shovels all the same anyway? As a tool both shovels perform the action just as fast, since its just one action, instead of several actions depending on the stage of rock/tree. The only difference between the two shovels is durability, and thats actually the same between the other tools and their variants as well. If you want better shovels, you can just make the custom shovels with more durability. Even if you want a more efficient hammer, you figured out the other two major tools, so I'm not really needed here.

 

EDIT: I get its a year from when you posted this, but you had no replies, so I figured if you're still even working on this I'd at least try to help

Edited by Dragolantis
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...