Calling the value of a varible in a message

So what I want to do is have a message, and in the middle insert the value of a variable.
so if variable player.eye_color = blue
then
msg ("Wow you are the loveliest shade of (Insert value of eye color here), I'm quite jealous.")
How can I do that?


You can insert an attribute in a message using the text processor.
msg ("Wow you are the loveliest shade of {player.eye_color}, I'm quite jealous.")

You can also use the + operator to join strings together:
msg ("Wow you are the loveliest shade of " + player.eye_color + ", I'm quite jealous.")
This method works with both variables and attributes.


Oh thank you, ya I was trying to do the first one copying some code some one gave me but it didn't work and now I see why.
Around the player.eye_color, they had () instead of {}
Also the second one I tried to do that and thought of that exact code, but didn't try it because I thought it wouldn't work lol


you can (I think) insert a Function that returns a string into a 'msg' Script/Function as well (which might have been the code you were looking at):

msg ("Hi, my name is " + example_function () + ".")

// ------------------

<function name="example_function" type="string">
  return ("HK")
</function>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums