I want to make it so that when my hero enters a region, a nearby npc will say one of 3 things randomly through a text tag above their head. I am still a huge noob with the editor, so its probably very simple, but perhaps someone could point me in the right direction.
How about if I want to destroy the former text tag every time I re-enter the region so that they aren't overlapping? I tried putting a 'destroy last text tag' as the very first action in the trigger above all of the if-thens, but it doesn't seem to be working. Any ideas?
@Atl0s
Care to explain the difference? The last time I did any programming was with Qbasic about 15 years ago LOL
case's or switches do the same thing as a nested if then else (some languages even compile them the exact same) but they are easier to read and will fire faster in more advanced languages.
Why use cases and if's when all you need to do is create a text array and send then use this to create them.
Text Tag - Create a text tag with the text testMsgs[(Random integer between 0 and 2)] for (All players), using a font size of 24, at (Position of (Triggering unit)) and height offset 1.0, initially Visible, and fog of war enforcement set to false
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I want to make it so that when my hero enters a region, a nearby npc will say one of 3 things randomly through a text tag above their head. I am still a huge noob with the editor, so its probably very simple, but perhaps someone could point me in the right direction.
@voodude2008: Go
It is pretty simple but can be confusing to figure out. Lets say your 3 text tags are "Hi, Hello, and Hey"
Now you want a variable that's an integer. then this trigger or something similar.
To set the variable into a random integer do this function:
Set Variable
Variable: RandomTxtTag
Value: Random Integer
Min: 1
Max: 3
@ZeroAme: Go
You rock dude :D
Just a note - cases are a lot easier to work with for these sort of things instead of using multiple if then elses.
@voodude2008: Go
How about if I want to destroy the former text tag every time I re-enter the region so that they aren't overlapping? I tried putting a 'destroy last text tag' as the very first action in the trigger above all of the if-thens, but it doesn't seem to be working. Any ideas?
@Atl0s
Care to explain the difference? The last time I did any programming was with Qbasic about 15 years ago LOL
@voodude2008: Go
Bump?
Assign a text tag a variable and detroy them by referencing that variable name
or...if you don't use any other dialog items in that dialog, you can just use "Destroy All Dialog Items"
@voodude2008: Go
case's or switches do the same thing as a nested if then else (some languages even compile them the exact same) but they are easier to read and will fire faster in more advanced languages.
Example;
@DarkShape80: Go
Cool, thanks guys :D
Why use cases and if's when all you need to do is create a text array and send then use this to create them.
Text Tag - Create a text tag with the text testMsgs[(Random integer between 0 and 2)] for (All players), using a font size of 24, at (Position of (Triggering unit)) and height offset 1.0, initially Visible, and fog of war enforcement set to false