Difference between revisions of "ChangeOutfit (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m (Text replacement - "wikitable" to "ts")
Line 11: Line 11:
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/>
 
2a. To change the outfit of the current character...
 
2a. To change the outfit of the current character...
<syntaxhighlight>
+
<syntaxhighlight lang="lua">
changeOutfit("", "outfit_name")
+
changeOutfit(nil, "outfit_name")
 
</syntaxhighlight>
 
</syntaxhighlight>
 
2b. To change the outfit of a specific character...
 
2b. To change the outfit of a specific character...
Line 23: Line 23:
 
<syntaxhighlight>
 
<syntaxhighlight>
 
function changeOutfit(c, o)
 
function changeOutfit(c, o)
  if c = "" then c = game:getLink(VGameCurrentCharacter) else c = getObject("Characters[" .. c .. "]") end
+
  if c ~= nil then c = Characters[c] else c = game.CurrentCharacter end
  o = c:getObject(".CharacterOutfits[" .. o .. "]")
+
  c.CurrentOutfit = c.Outfits[o]
c:setValue(VCharacterCurrentOutfit, o)
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 34: Line 33:
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description
 
|-
 
|-
| c || "string" || This should be a "string" value containing the name of the character you want to affect; if string is empty it will default to current character.
+
| c || "string" or nil || This should be a "string" value containing the name of the character you want to affect; if c equals nil then it will default to current character.
 
|-
 
|-
 
| t || "string" || This should be a "string" value containing the name of the outfit you want to change to.
 
| t || "string" || This should be a "string" value containing the name of the outfit you want to change to.
 
|}
 
|}

Revision as of 12:30, 20 April 2022

Name Type By
changeOutfit("c", "o") Definition AFRLme

This small function allows you to quickly change the outfit of a character.

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. To change the outfit of the current character...

changeOutfit(nil, "outfit_name")

2b. To change the outfit of a specific character...

changeOutfit("character_name", "outfit_name")


Main Script

function changeOutfit(c, o)
 if c ~= nil then c = Characters[c] else c = game.CurrentCharacter end
 c.CurrentOutfit = c.Outfits[o]
end

Syntax Breakdown

Name Type Description
c "string" or nil This should be a "string" value containing the name of the character you want to affect; if c equals nil then it will default to current character.
t "string" This should be a "string" value containing the name of the outfit you want to change to.