Requesting help with truncate() [SOLVED: USER ERROR]

aphroguy

New member
As part of my daily breakfast routine, I have a snippet that doesn't seem to work the way I had intended. I wrote it without any of my characters in Ronin, and because it checks Ronin status, I had no way of testing it for several months.

When I was able to test it, it didn't quite work the way I had hoped. Here's the snippet:

Code:
if (my_turncount() <= 1000) {
	int pumps = my_adventures();
	int pumpseach = truncate( pumps / 3 );
	print("Because you are still in Ronin, you will be working out for " + pumpseach + " adventures for each stat.");
	cli_execute("adventure " + pumpseach + " pump up moxie");
	cli_execute("adventure " + pumpseach + " pump up mysticality");
	cli_execute("adventure " + pumpseach + " pump up muscle");
}

I remember I was referencing the Ash Wiki while writing this, and found the truncate() function to do exactly what I needed, split whatever adventures I have remaining three ways and pump up each stat equally.

However, when I run the script, it prints, "...you will be working out for 0 adventures...", despite having 200 adventures at the moment. I was under the impression that it would take remaining adventures and divide by three (200/3=66.6666) then just drop the decimal and adventure for 66 turns for each stat. Some how, though, it's getting zero and adventuring for zero turns each stat. Am I just misunderstanding the use of truncate()?
 

macman104

Member
Re: Requesting help with truncate()

Can you try adding
Code:
print(pumps);
print(pumps/3);
Also, I don't even know if you need truncate. Truncate is for float values, pumps and 3 are both integer values and should thus give you 66 even without truncate. But from what I can see in the source code truncate does exactly what you think it does. Maybe it's returning zero if you pass it an integer?
 

aphroguy

New member
macman104 - Thanks for the reply. Both of those returned zero, and I see why now. The first time I ran the script, it was encased in a while statement, rather than an if statement. This caused it to execute correctly the first time, then just loop through. I fixed the loop before posting, but obviously had no adventures and failed to notice the adventures were actually spent initially. Completely my bad, sorry to waste your time! :-X
 
Top