Jump to content

Help with character's unique scripts


Recommended Posts

-I would like to have my character say only a set few phrases, like Wilton or Wilbur, but I don't know the scripts, or where to put them.

-And, uh, this is kind of a weird question, but is it possible to make my character drop every tool they try to equip? Like when someone tries to pick up Lucy the Axe? They don't have arms, and it would be weird to have floating tools. I was planning on making them dependent on other players, if you're curious.

Edited by JackyHann
Carry instead of equip.
Link to comment
Share on other sites

On 20/6/2016 at 3:04 PM, JackyHann said:

-I would like to have my character say only a set few phrases, like Wilton or Wilbur, but I don't know the scripts, or where to put them.

local random_sayings = {
	"hello",
	"how",
	"are",
	"you",
	"today",
}

local function PickRandomFromSayings()
	return random_sayings[math.random(#random_sayings)]
end

local _GetSpecialCharacterString = GLOBAL.GetSpecialCharacterString

GLOBAL.GetSpecialCharacterString = function(character)
	character = character and string.lower(character)
	return (character == "wilson" and PickRandomFromSayings()) or _GetSpecialCharacterString(character)
end

In modmain. Change wilson for your character prefab.

On 20/6/2016 at 3:04 PM, JackyHann said:

drop every tool they try to equip? Like when someone tries to pick up Lucy the Axe?

AddPrefabPostInit("wilson", function(inst)
	if inst.components.inventory then
		inst:ListenForEvent("equip", function(inst, data)
			if data and data.item and data.eslot == GLOBAL.EQUIPSLOTS.HANDS then
				inst.AnimState:Hide("arm_carry")
				inst.AnimState:Show("arm_normal")
				inst:DoTaskInTime(0, function(inst)
					inst.components.inventory:DropItem(data.item, true, true)
				end)
			end
		end)
	end
end)

In modmain. Change wilson for your character prefab.

Link to comment
Share on other sites

I try to do this but not work from me. I'm new at coding what's wrong

 

PrefabFiles = {
    "azura",
}

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

    Asset( "IMAGE", "images/selectscreen_portraits/azura.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/azura.xml" ),
    
    Asset( "IMAGE", "images/selectscreen_portraits/azura_silho.tex" ),
    Asset( "ATLAS", "images/selectscreen_portraits/azura_silho.xml" ),

    Asset( "IMAGE", "bigportraits/azura.tex" ),
    Asset( "ATLAS", "bigportraits/azura.xml" ),
    
    Asset( "IMAGE", "images/map_icons/azura.tex" ),
    Asset( "ATLAS", "images/map_icons/azura.xml" ),

}

local require = GLOBAL.require

-- The character select screen lines
GLOBAL.STRINGS.CHARACTER_TITLES.azura = "Azura The FallenFox"
GLOBAL.STRINGS.CHARACTER_NAMES.azura = "Azura"
GLOBAL.STRINGS.CHARACTER_DESCRIPTIONS.azura = ""
GLOBAL.STRINGS.CHARACTER_QUOTES.azura = "\"Asobi No Iku Yo\""

-- Custom speech strings
GLOBAL.STRINGS.CHARACTERS.AZURA = require "speech_azura"

-- Let the game know character is male, female, or robot
table.insert(GLOBAL.CHARACTER_GENDERS.FEMALE, "azura")


AddMinimapAtlas("images/map_icons/azura.xml")
AddModCharacter("azura")

local random_sayings = {
    "hello",
    "how",
    "are",
    "you",
    "today",
}

local function PickRandomFromSayings()
    return random_sayings[math.random(#random_sayings)]
end

local _GetSpecialCharacterString = GLOBAL.GetSpecialCharacterString

GLOBAL.GetSpecialCharacterString = function(azura)
    character = character and string.lower(azura)
    return (character == "azura" and PickRandomFromSayings()) or _GetSpecialCharacterString(azura)
end
 

Link to comment
Share on other sites

6 hours ago, AkaiNight said:

local random_sayings = {
    "hello",
    "how",
    "are",
    "you",
    "today",
}

local function PickRandomFromSayings()
    return random_sayings[math.random(#random_sayings)]
end

local _GetSpecialCharacterString = GLOBAL.GetSpecialCharacterString

GLOBAL.GetSpecialCharacterString = function(azura)
    character = character and string.lower(azura)
    return (character == "azura" and PickRandomFromSayings()) or _GetSpecialCharacterString(azura)
end

Should be:

local random_sayings = {
	"hello",
	"how",
	"are",
	"you",
	"today",
}

local function PickRandomFromSayings()
	return random_sayings[math.random(#random_sayings)]
end

local _GetSpecialCharacterString = GLOBAL.GetSpecialCharacterString

GLOBAL.GetSpecialCharacterString = function(character)
	character = character and string.lower(character)
	return (character == "azura" and PickRandomFromSayings()) or _GetSpecialCharacterString(character)
end

character is a variable for that function.

Link to comment
Share on other sites

I am sorry i fix it and i don't know how to delete a reply. But it's only working when i try to attack. Can't i make it randomly in day?

and thanks for answer

sorry for english not my first language

Edited by AkaiNight
i forgot the tank
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...