|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Sat Jan 10, 2009 6:46 pm
#math and decimals |
I"m trying to midas items, and give the coins back to whomever gave me the item, keeping a percentage for myself.
I have the majority of things done, but when I try (for example) to midas something that's worth 83333 coins, I have the process like this..
#math mygold (@itemgold*.02)... problem is, in this case, the mygold portion ends up being 1666.66.. and it throws my triggers into a spin with the next line..
#math chargold @itemgold-@mygold
give @chargold coins @char
it won't let me give partials.. 1666.66.. "I'm sorry, you can't do that"
how can I set it up so that it rounds to the nearest coin on the @mygold math process?
if it helps, here is the goldend step of the process
Code: |
#math itemgold @endgold-@startgold
#math mygold (@itemgold*.02)
#math chargold @itemgold-@mygold
#say Item gold is @itemgold
#say My gold is @mygold
#add tgold @tgold+@mygold
#add tmidasgold @tmidasgold+@tgold
#say I midas'd @Item.name for @itemgold gold pieces. Your share is @chargold gold pieces.
give @chargold coin @midchar
|
|
|
Last edited by Ralph1971 on Sat Jan 10, 2009 6:51 pm; edited 1 time in total |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Sat Jan 10, 2009 6:49 pm |
you could force it into an integer, and use %mod to add the remainder back on.
#MATH mygold (%int(@itemgold*.02)+%mod(@itemgold/50)) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Scirkhan Apprentice
Joined: 14 Sep 2007 Posts: 167 Location: aztx
|
Posted: Mon Jan 12, 2009 11:43 am |
This line of code looks like what you are wanting:
Code: |
#math mygold (%round(@itemgold*0.02)) |
#eval
%eval
%int
%mod
%round <---
Are all very useful.
#MATH mygold @itemgold/50
#MATH mygold (@itemgold/50+%mod(@itemgold/50))
#MATH mygold (%int(@itemgold*0.02))
#MATH mygold (%int(@itemgold/50))
#MATH mygold (%int(@itemgold/50)+%mod(@itemgold/50))
give @itemgold%round(@itemgold-@itemgold*0.02) coin @midchar
give %eval(@itemgold-@itemgold/50) coin @midchar
-------------------------------------------------------------------------
For some reason *.02 doesn't work for me. So:
#math mygold (@itemgold*.02) didn't work for me. I don't know why but what I've found is
#math mygold @itemgold/50 doesn't give floating numbers.
NOTE: "/" truncates, does not give floating numbers.
*0.02 worked for me. *.02 doesn't. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Mon Jan 12, 2009 8:35 pm |
if you change it to /50.0 it should give a float
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|