Jump to content

Help with verifying strings


Recommended Posts

 
d8ebf2badc14b0ef24a1f556409985c7-full.jpg

My goal right now is to create a random generated speech within companions to make them feel more alive and to kinda make me not feel alone :( . but ly it keeps on registering it as not a string. i know that i added it to the modmain yet it still doesn't show up. 

please if you can help me that would be awsome, i'll poste the code for the follower and the string

local assets =
{
    Asset("ANIM", "anim/perd_basic.zip"),
    Asset("ANIM", "anim/perd.zip"),
    Asset("SOUND", "sound/perd.fsb"),
}

local brain = require "brains/smperdbrain"

local MAX_TARGET_SHARES = 5
local SHARE_TARGET_DIST = 30

local function nicewords(inst)
	inst.components.talker:Say(GetString(inst, "CHATTER"))
	end

local function OnDeath(inst)
    SpawnPrefab("small_puff").Transform:SetPosition(inst.Transform:GetWorldPosition())
    inst:Remove()
end

local function OnStopFollowing(inst) 
    --inst:RemoveTag("companion") 
end

local function OnStartFollowing(inst) 
    --inst:AddTag("companion") 
end

local function KeepTarget(inst, target)
    if inst.components.health.currenthealth < (inst.components.health.maxhealth/10) then
        return false
    else
        return inst.components.combat:CanTarget(target) and inst:IsNear(target, 10) -- Hounds keep target for 10
    end
end

local function OnAttacked(inst, data)

    inst.components.combat:SetTarget(data.attacker)
    inst.components.combat:ShareTarget(data.attacker, SHARE_TARGET_DIST, function(dude) return dude.prefab == inst.prefab end, MAX_TARGET_SHARES)
end

local function OnNewTarget(inst, data)
    inst.components.combat:ShareTarget(data.target, SHARE_TARGET_DIST, function(dude) return dude.prefab == inst.prefab end, MAX_TARGET_SHARES)
end

local function die(inst)
	inst.components.health:Kill()
end

local function KeepTarget(isnt, target)
    return target and target:IsValid()
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddDynamicShadow()
    inst.entity:AddLightWatcher()
    inst.entity:AddNetwork()

    inst.AnimState:SetBuild("perd")

    MakeCharacterPhysics(inst, 50, .5)

    inst.DynamicShadow:SetSize(1.5, .75)
    inst.Transform:SetFourFaced()

    inst:AddTag("companion") 

    inst:AddTag("dab") 

    inst.AnimState:SetBank("perd")
    inst.AnimState:PlayAnimation("idle_loop", true)
    inst.AnimState:Hide("hat")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end


    inst:AddComponent("locomotor")
    inst.components.locomotor.runspeed = TUNING.PERD_RUN_SPEED
    inst.components.locomotor.walkspeed = TUNING.PERD_WALK_SPEED
    ------------------------------------------
    inst:AddComponent("eater")
    inst.components.eater:SetDiet({ FOODTYPE.VEGGIE }, { FOODTYPE.VEGGIE })
    inst.components.eater:SetCanEatRaw()

    ------------------------------------------
    inst:AddComponent("combat")
    inst.components.combat.hiteffectsymbol = "pig_torso"
    ------------------------------------------
    inst:AddComponent("health")
    inst.components.health:StartRegen(TUNING.BUNNYMAN_HEALTH_REGEN_AMOUNT, TUNING.BUNNYMAN_HEALTH_REGEN_PERIOD)

    ------------------------------------------
    MakeMediumFreezableCharacter(inst, "pig_torso")
    MakeMediumBurnableCharacter(inst, "pig_torso")

    ------------------------------------------

    inst:AddComponent("follower")
    inst:ListenForEvent("stopfollowing", OnStopFollowing)
    inst:ListenForEvent("startfollowing", OnStartFollowing)
    inst.components.follower.keepdeadleader = true

    ------------------------------------------

    inst:AddComponent("inspectable")

    ------------------------------------------

    inst:AddComponent("talker")
    inst.components.talker.fontsize = 35
    inst.components.talker.font = TALKINGFONT
        --inst.components.talker.colour = Vector3(133/255, 140/255, 167/255)
    inst.components.talker.offset = Vector3(0, -400, 0)

    -------------------------------------------

    inst:ListenForEvent("death", OnDeath)
  

    inst.components.health:SetMaxHealth(250)
    inst.components.combat:SetDefaultDamage(33)
    inst.components.combat:SetAttackPeriod(TUNING.PERD_ATTACK_PERIOD)
    inst.components.combat:SetKeepTargetFunction(KeepTarget)
    inst:ListenForEvent("newcombattarget", OnNewTarget)
    inst:ListenForEvent("attacked", OnAttacked)
    inst:DoPeriodicTask(1, function() nicewords(inst) end)

    inst:AddTag("frick")
    inst:AddTag("sm")

    inst:AddComponent("named")
    inst.components.named.possiblenames = STRINGS.SMPERD_NAMES
    inst.components.named:PickNewName()

    MakeHauntablePanic(inst, 5, nil, 5)

    inst:SetBrain(brain)
    inst:SetStateGraph("SGperd")

    return inst
end

return Prefab("smperd", fn, assets, prefabs)
 
                                                                                   
                                                                                   --this is for the modmain-----
                                                                                   
PrefabFiles = {
"wakadoodoo",
"smperd",
"eggd",
}

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

    Asset( "IMAGE", "images/selectscreen_portraits/wakadoodoo.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wakadoodoo.xml" ),
	
    Asset( "IMAGE", "images/selectscreen_portraits/wakadoodoo_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/wakadoodoo_silho.xml" ),

    Asset( "IMAGE", "bigportraits/wakadoodoo.tex" ),
    Asset( "ATLAS", "bigportraits/wakadoodoo.xml" ),
	
	Asset( "IMAGE", "images/map_icons/wakadoodoo.tex" ),
	Asset( "ATLAS", "images/map_icons/wakadoodoo.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_wakadoodoo.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_wakadoodoo.xml" ),
	
	Asset( "IMAGE", "images/avatars/avatar_ghost_wakadoodoo.tex" ),
    Asset( "ATLAS", "images/avatars/avatar_ghost_wakadoodoo.xml" ),

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

}

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

-- The character select screen lines
STRINGS.CHARACTER_TITLES.wakadoodoo = "wakadoodoo"
STRINGS.CHARACTER_NAMES.wakadoodoo = "wakadoodoo"
STRINGS.CHARACTER_DESCRIPTIONS.wakadoodoo = "*can summon his fellow tribe members\n*controlls an army of gobblers\n*is frail and weak"
STRINGS.CHARACTER_QUOTES.wakadoodoo = "\"Ooga Booga\""

-- Custom speech strings
STRINGS.CHARACTERS.WAKADOODOO = require "speech_wakadoodoo"

-- The character's name as appears in-game 
STRINGS.NAMES.WAKADOODOO = "wakadoodoo"

-- The default responses of examining the character
STRINGS.CHARACTERS.GENERIC.DESCRIBE.WAKADOODOO = 
{
	GENERIC = "It's wakadoodoo",
	ATTACKER = "That bush man looks shifty...",
	MURDERER = "Murderer!",
	REVIVER = "wakadoodoo, friend of ghosts.",
	GHOST = "wakadoodoo could use a heart.",
}

STRINGS.NAMES.SMPERD = "Bush Tribal"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.SMPERD = "strong fellas"

STRINGS.NAMES.EGGD = "egganomicon"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.EGGD = "what a wierd book"
STRINGS.RECIPE_DESC.EGGD = "only the shaman of the forest can summon the spirits"

AddRecipe("eggd",
	{
		Ingredient("bird_egg", 1),
		Ingredient("cutgrass", 6),
		Ingredient("dug_berrybush", 1),
	},
	RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, 'frick', "images/inventoryimages/eggd.xml")

STRINGS.SMPERD_NAMES = {
			"Billy",
			"Dipper",
			"Joe",
			"Jan",
			"Vito",
			"nome",
			"Peter",
}

STRINGS.SMPERD = {

    CHATTER =
    {
	"Kill two birds for the price of one.",
	"Give a man a fish and you lose a fish and he gets a fish",
	"Contrary to popular belief, the egg did not.",
	"i miss berries", 
	"I love you.",
	"i'll protect you",
	"i hope we get hats",
}

--
AddMinimapAtlas("images/map_icons/wakadoodoo.xml")

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

20190701161122_1.jpg

sorry i sent quite alot thnx anyway even if you read this

Link to comment
Share on other sites

It's telling you what's wrong...sort of :) IIRC speech files cannot handle having several strings for the same key, in this case "STRINGS.SMPERD.CHATTER". Also, you haven't closed the CHATTER collection.

STRINGS.SMPERD = {

    CHATTER =
    {
	"Kill two birds for the price of one.",
	"Give a man a fish and you lose a fish and he gets a fish",
	"Contrary to popular belief, the egg did not.",
	"i miss berries", 
	"I love you.",
	"i'll protect you",
	"i hope we get hats",
    -- missing } here
}

You could do something like this instead:

local function nicewords(inst)
	inst.components.talker:Say(GetString(inst, "CHATTER" .. math.random(1, 7)))
end

STRINGS.SMPERD = {

    CHATTER =
    {
	    CHATTER1 = "Kill two birds for the price of one.",
	    CHATTER2 = "Give a man a fish and you lose a fish and he gets a fish",
	    CHATTER3= "Contrary to popular belief, the egg did not.",
	    CHATTER4 = "I miss berries", 
	    CHATTER5 = "I love you.",
	    CHATTER6 = "I'll protect you",
	    CHATTER7 = "I hope we get hats",
	}
}

 

Link to comment
Share on other sites

Hmm, strange. I must admit I haven't messed around with stored strings. Reading GetString() in stringutil.lua shows why this isn't working. I don't think you actually have to use the STRINGS, but there may be something about sharing the strings with the other players, so instead of just creating a local list of strings and foregoing STRINGS. lets try to make this work.

So, GetString() only retrieves generic or character-specific character strings. This line in particular is important for your purposes:

or getcharacterstring(STRINGS.CHARACTERS[character], stringtype, modifier)
or getcharacterstring(STRINGS.CHARACTERS.GENERIC, stringtype, modifier)

As you can see here, it only gets strings which are placed underneath STRINGS.CHARACTERS (aside from some "special character" strings, like those for ghosts). So we can either add all the strings to the CHARACTERS sub-list, or forego using GetString() entirely.

Here's how to do the latter, which I think makes the most sense:

local function nicewords(inst)
	inst.components.talker:Say(STRINGS.SMPERD.CHATTER["CHATTER" .. math.random(1, 7)]))
end

STRINGS.SMPERD = {

    CHATTER =
    {
	    CHATTER1 = "Kill two birds for the price of one.",
	    CHATTER2 = "Give a man a fish and you lose a fish and he gets a fish",
	    CHATTER3= "Contrary to popular belief, the egg did not.",
	    CHATTER4 = "I miss berries", 
	    CHATTER5 = "I love you.",
	    CHATTER6 = "I'll protect you",
	    CHATTER7 = "I hope we get hats",
	}
}

 

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