ID:269145
 
Is there a way to code basic math? For example: Taking your level multiplying it by 3 and dividing it by your health. I kinda need to figure this one out for a very complex statmeter system so if anyone can help , it would be very much appreciated. Thanx.
Hiro the Dragon King wrote:
Is there a way to code basic math? For example: Taking your level multiplying it by 3 and dividing it by your health. I kinda need to figure this one out for a very complex statmeter system so if anyone can help , it would be very much appreciated. Thanx.

Sure there is!
var/the_result = (src.level*3)/src.health

The * operator multiplys, and the / operator divides. Parenthesis, as they do in math, tell the compiler to evaluate the expression contained inside of the parenthesis first.
In response to Wizkidd0123
How about doing that inside of quotations to like display my name as my level divided by my stat?
In response to Hiro the Dragon King
Hiro the Dragon King wrote:
How about doing that inside of quotations to like display my name as my level divided by my stat?

What do you mean? Can you rephrase that please?
In response to Hiro the Dragon King
If you mean embedding it in a text string so that the text string equates to the text equivalent of the number you want, then yes. You can do that.
mob/verb/damaged(N)
hp-=N
name="[initial(name)] the [desc]: [hp]HP"

In response to Wizkidd0123
Um, how to phrase this.
Okay let me just put it exactly as I am working on it.

The stat varies from 0000-3000 & the experince varies from 0-10. But, both are to be displayed with the same icon. Since the meter has 61 places to fill 3001 in stats and 11 places to fill 11 in exp, I need to code a mathematical equation to where the icon state would be the stat doubled then divided by 100 and rounded down to the nearest whole number, followed by the exp.

Example:
mob
var
stat = 1357
exp = 4
and using that to make the icon state be:
icon_state = "274"

If you still don't follow I don't know if I can put it any simpler.

Basically I need to know how to code rounding quotients and put mathematical equaitons inside of quotes like names or icon states.
In response to Loduwijk
Thanx. And I have more to ask.
In response to Hiro the Dragon King
Hiro the Dragon King wrote:
Basically I need to know how to code rounding quotients >

Use round().

put mathematical equaitons inside of quotes like names or icon states.

You would use embedded text for this.

src.text_value_variable="[10/1000]"


Embedded text can also be used to refer to other variables:

src.text_value_variable="Your health is equal to[src.health]."


You can even use both!

src.text_value_variable="Your health, when divided by 1000, is equal to [src.health/1000]."