Jump to content
  • 0

Adding variables to text output and performing math in strings.


NetSkeleton

Question

Hello, I am tinkering with making a game in this engine and have run into something I am confused about. 

 

I found that in an event you can add  \pv{Variable} to output the value of a variable in your text but when I attempt to do this it does not appear to work. 

 

My first question is how should the above be formatted to show the value of a variable in chat or in a text window.

 

My second question would be can I perform math in that so that I can change the output results? 

 

Example: You have \pv{attack + 2} attack points!

 

If what I am talking about above is possible, what operators are allowed? 

 

Thank you in advance for your assistance. 

 

NetSkeleton.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Quick sloppy explanation:

 

Variables hold data to use later. We can call the values that we set to the variables. Example:

 

Type = Integer (number)

Name = attackValue

 

Now in an event we can set, add, subtract, ect to an integer variable, then we call that variable to see its value by using \pv{attackValue} in an event.

 

So I would have the event write out like this:

 

Set Variable attackValue to 4

Set display Chat Message to:

"Attack has be set to \pv{attackValue}" which would show "Attack has be set to 4"

 

Hope that makes sense but look about the forum, loads of tutorials on how events work. Read some of mine and that will give you an understanding :P a good one would be Journal/Tradeskills as that shows how variables write out a lot: 

 

Link to comment
Share on other sites

  • 0

Ok wonderful thank you, I will read your guides as I am sure it will help a lot. 

 

I assume by this answer it is only possible to do the math first and then output the result in a string after the fact and not possible to do math during the string output?

 

I was hoping to do something like setting an amount of milliseconds to a variable and then dividing the variable output in the string so I could show seconds to the player instead.

 

Example:

 

Set variable time = 10000

 

Chatbox text would output: You have \pv(time) / 1000 seconds remaining.

 

Expected output to player: you have 10 seconds remaining.

 

Is this possible?

 

Thank you for your assistance and advice. : )

 

 

Link to comment
Share on other sites

  • 0
On 1/4/2024 at 11:57 PM, NetSkeleton said:

Ok wonderful thank you, I will read your guides as I am sure it will help a lot. 

 

I assume by this answer it is only possible to do the math first and then output the result in a string after the fact and not possible to do math during the string output?

 

I was hoping to do something like setting an amount of milliseconds to a variable and then dividing the variable output in the string so I could show seconds to the player instead.

 

Example:

 

Set variable time = 10000

 

Chatbox text would output: You have \pv(time) / 1000 seconds remaining.

 

Expected output to player: you have 10 seconds remaining.

 

Is this possible?

 

Thank you for your assistance and advice. : )

 

 


You could do something easy as this:

40f59cad2bf64f46dcb554d85a26f460.png

Which will end up with what you want
47c824c8897c8905b00a27c92abf3527.png

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
×
×
  • Create New...