Author Topic: problem with input_to  (Read 2015 times)

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
problem with input_to
« on: October 22, 2006, 10:21:18 AM »
Ok, just showing part of the code (the part that's giving me a problem, the rest works great)...



code:
int SetAgility(string str)
{
 int y;
 y = this_player()->GetAttributePoints();
 write("You have decided to raise your agility. You have %^ORANGE%^" + y + " %^RESET%^points to spend");
 write("How many would you like to spend?\n");
 input_to((: process_agility :));
 return 1;
}

int process_agility(int str)
{
int z;

this_player()->SetStat("agility", str);
z = this_player()->GetStatLevel("agility");

write("You raise your agility %^BOLD%^%^BLUE%^" + str + " %^RESET%^points to a total of %^BOLD%^%^ORANGE%^" + z + "%^RESET%^!\n");
return 1;
}






Every time my test character gets to the point where they will decide how many points to spend a runtime error occurs, the run time error is:

quote:


*Bad argument 2 to >=

Expected: string Got: 1.

Object: /secure/save/players/t/test (/lib/genetics.c) at line 95



'<function>' at /domains/creation/room/statistics (<function>) at /:0

'process_agility' at /domains/creation/room/statistics at line 99

'SetStat' at /secure/save/players/t/test (/lib/race.c) at line 137

'SetStat' at /secure/save/players/t/test (/lib/genetics.c) at line 95




I think this means that the number being input by the test character is not being properly fed through SetStat("agility", str)... but Im not sure if that really is the problem, or if it is how to fix it.



Any input on how to fix this would be appreciated.  Thank you.

Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
problem with input_to
« Reply #1 on: October 22, 2006, 01:32:25 PM »
Fixed.

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1020
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
problem with input_to
« Reply #2 on: October 22, 2006, 05:50:05 PM »

I'm a little late to the party, but I would guess the problem

was that input_to sends a string, but your function wanted

an int.



To turn an input_to string argument into an int, you

might want to use atoi. For example:



int InputFunction(string numstr){

int numint = atoi(numstr);

return numint;

}



-Crat

http://dead-souls.net">http://dead-souls.net/



Offline capo

  • Friend
  • **
  • Posts: 70
    • View Profile
problem with input_to
« Reply #3 on: October 22, 2006, 07:05:20 PM »
That would definately work, I used to_int, works great now!