I'm trying to create temporary number values and adding them to a *created variable


#1

I’m having trouble with trying to make 3 temporary variables, and then adding them all to a *create variable so they can be used in the future.
I want to track the number of catches someone makes throughout the entire game.

The error I’m getting is:
Error: Mission_2 line 29: Invalid expression at char 7, expected NUMBER, STRING, VAR or PARENTHETICAL, was: EQUALITY [=]

My code looks like this:

How many pidgeons did you end up catching?
 
Catch
*temp catch_1 
*set catch_1 0 
*temp catch_2 
*set catch_2 0
*temp catch_3 
*set catch_3 0
*input_number catch_1 0 100
*if ( catch_1 <10 )
 Ah, that's not enough! Please go get me some more.
 *goto_scene Mission_2
*else
 Whoa good job!
 *line_break
 Did you catch any of it's evolutions?
 Pidgenottos?
 *input_number catch_2 0 100
 *if ( catch_2 >1 )
  Excellent!
 Pidgeonots?
 *input_number catch_3 0 100
 *if ( catch_3 >1 )
  Well aren't you are a hard worker!

 *set catch = catch_1
 *set sparkledust = 100* catch
*goto mission2

#2

Have you tried taking out the equal sign in this: *set catch = catch_1


#3

just did and it fixed that error but then cause the sparkle dust at the end to bug up. am i allowed to do multiplication and addition with the catch variable?


#4

You’ve got the equal’s sign in
*set sparkledust
as well. Also, I find it helps to keep all operators in parentheses (not needed but it keeps things tidy.

So

*set sparkledust (100*catch)

Also, at the start of your code, you don’t need to perform *temp and *set

*temp catch_x 0 

works just as well


#5

Yep, either that way or:

*set sparkledust (catch * 100)

#6

Why do this when you can do

*temp catch_1 0
*temp catch_2 0
*temp catch_3 0

#7

because i was trying to fix the error and wasnt exactly certain how temp worked


#8

alright thanks!
but now ive tried to do the following code

*set catch =(catch_1 + catch_2 + catch_3)

but get the error:
Invalid expression at char 7, expected NUMBER, STRING, VAR or PARENTHETICAL, was: EQUALITY [=]


#9

oh wait no equal sign needed right?


#10

remove the “=” :joy:

edit - yes


#11

Correct. Take the equal sign out of *set catch =(catch_1 + catch_2 + catch_3) and also make sure to put enough parentheses to account for all three of those variables.


#12

do it like

*set catch (( catch_1 + catch_2 ) + catch_3 )

#13

oh alright thanks. why does it have to be cascading may i ask? just curious about the code


#14

I believe it’s because the program can only perform one operation (or process two variables) at a time. So the above example would be read something like:
catch_1 + catch_2
[total] + catch_3
*set catch [total]


#15

ah alright that makes sense
thanks