Difference between revisions of "UpdateCharName (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | updateCharName() || Definition || A...")
 
m
 
(6 intermediate revisions by the same user not shown)
Line 6: Line 6:
 
|}
 
|}
  
This small function allows you to quickly update a characters name on mouse over during runtime for any characters whose names you want to dynamically update.
+
This small function allows you to quickly update a characters name on mouse over during runtime for any characters whose names you want to dynamically update, because the player learns their names over time or because you decided to allow the player decide on certain characters names themselves.
  
  
Line 16: Line 16:
 
Characters["Tom"].Values["character_name"].String = "Jerry"
 
Characters["Tom"].Values["character_name"].String = "Jerry"
 
</syntaxhighlight>
 
</syntaxhighlight>
3. You should also create a condition in the conditions tab for the character & name it something like "name_discovered" & set it as <span class="green">false</span> by default. Change it to true when you want to use the new name.
+
3. Create mouse enters actions for all of the characters whose name you want to update & create an execute a script action part & insert this line of code...
4. Inside of the actions section of any character you want to change the name of you will need to create some actions like this...
 
if condition "name_discovered" is true
 
execute a script
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
updateCharName()
 
updateCharName()
 
</syntaxhighlight>
 
</syntaxhighlight>
end if
 
  
  
Line 42: Line 38:
  
 
end
 
end
</syntaxhighlight>{{toc}}
+
</syntaxhighlight>
 +
<hr>
 +
{| class="ts"
 +
|-
 +
| ''Quick note: don't forget that you need to insert the default name of the character into the name input box for each language inside of the properties section of the character, otherwise it won't draw the text for any of the names linked to x language that have been left empty.''
 +
|}{{toc}}

Latest revision as of 16:35, 14 September 2022

Name Type By
updateCharName() Definition AFRLme

This small function allows you to quickly update a characters name on mouse over during runtime for any characters whose names you want to dynamically update, because the player learns their names over time or because you decided to allow the player decide on certain characters names themselves.


Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2a. For any characters that you want to change the name of you need to include a value inside of their values tab & call it "character_name", & then inside of the String section you should include the default name of the character that you want to use.
2b. To update a characters name you would do something along the lines of this inside of an execute a script action part...

Characters["Tom"].Values["character_name"].String = "Jerry"

3. Create mouse enters actions for all of the characters whose name you want to update & create an execute a script action part & insert this line of code...

updateCharName()


Main Script

function updateCharName()

 local n = game.CurrentObject.Name.TextLanguages

 for i = 1, #n do

  n[i].text = game.CurrentObject.Values["character_name"].String

 end

 game.CurrentObject.Name.TextLanguages = n

end

Quick note: don't forget that you need to insert the default name of the character into the name input box for each language inside of the properties section of the character, otherwise it won't draw the text for any of the names linked to x language that have been left empty.