Post new topic    
Liquid Metal Slime
Send private message
Input String 
 PostFri Sep 02, 2011 7:47 pm
Send private message Reply with quote
I'm trying to figure out a way to allow the player to input something into a string and the string save that information. I don't think I've been successful as of yet.

Is the input string command what I should be working with to make this happen? If so, I must be using it wrong. This is what I got...

Code:
script,alminegate,begin
   suspend player
   show textbox (1191)
   wait for textbox
   clear string (4)
   append number (4,135)
   show textbox (1194)
   wait (15)
   advance text box
   input string (5, 2)
   if (string compare (4,5) == true) then (
      show textbox (1193)
      wait for textbox)
   else (
      show textbox (1)
      wait for textbox)
   clear string (5)
   resume player
end

Cornbread Chemist
Metal Slime
Send private message
 
 PostFri Sep 02, 2011 7:57 pm
Send private message Reply with quote
Well, right now string 4 has the ascii rep of the number 135, but you are only allowing the player to input two characters into string 5:
Code:
input string (5,2)


The second argument of input string is the max length allowed to be input by the player. What was this 2 supposed to be accomplishing?
I am Srime
Liquid Metal Slime
Send private message
 
 PostFri Sep 02, 2011 8:06 pm
Send private message Reply with quote
It's actually 3, sorry. I allowed only two to be entered briefly to test something and forgot to put it back to 3. Even with three it doesn't work for me though.
Cornbread Chemist
Metal King Slime
Send private message
 
 PostSat Sep 03, 2011 6:14 am
Send private message Reply with quote
The problem is with stringcompare. It turns out that it return -1 (which is the value freebasic uses for 'true') instead of 1 which is the value of the 'true' constant. Get rid of the "== true". While this is a bug in stringcompare which I'll fix, in general writing "== true" is not a great idea, because it's pointless and there might be more commands with this problem.
Liquid Metal Slime
Send private message
 
 PostSat Sep 03, 2011 5:21 pm
Send private message Reply with quote
If you're using numbers, you might be better off using "number from string." This command reads numbers the way that "input string" reads words, except that you're storing the number directly into a variable.

Code:
input string (4,3,true,false,195,175)
youranswer := number from string (4,-1)
if (youranswer==myanswer) then(
#eliminate the complicated middleman
)
end

Place Obligatory Signature Here
Liquid Metal Slime
Send private message
 
 PostSun Sep 04, 2011 9:12 pm
Send private message Reply with quote
That did the trick guys, thanks!
Cornbread Chemist
Display posts from previous: