Coding trouble -Invalid expression, couldn't extract another token:-


#1

I am having trouble with some of my code, and after scratching my head for a few days I thought it would be better to ask… what is wrong with the code below? Any ideas? It seems to give me an error on the expression

        *if (money > (cost_torpedo*1)) #One salvo of torpedoes

Invalid expression, couldn’t extract another token

Full code below…

*choice

  #Dock your ship at the space station's shipyard (for repairs or buying ammunition, etc)

     You dock your ship at the space station's shipyard, and within a few minutes one local official appears on the main screen, asking what they can do for you.

     *label shipyard_choices

     *choice

        #Tell him that you are not interested in anything and proceed somewhere else 
            *goto finished_station
   

        *if (ship_ammo < ship_maxammo) #Tell him that you are interested in buying ammunition for your proton torpedoes

            The official nods, and inquires how much ammunition would you like to buy

            [Note that you currently have ${ship_ammo} and the maximum you can hold is ${ship_maxammo}, any purchases over this amount will be lost]

            *if (money > (cost_torpedo*1)) #One salvo of torpedoes
               *set ship_ammo +1
               *set money -(cost_torpedo*1)
               *goto finish_buying_ammo

#2

I think you’re missing a set of parentheses there, possibly? Try:

*if ((money) > (cost_torpedo*1)) #One salvo of torpedoes

#3

The #One salvo line is too indented.


#4

Your if statement looks correct, but it’s missing a *choice statement. So it probably doesn’t know what to make of the # on the same line. Try this:

         *if (ship_ammo < ship_maxammo) #Tell him that you are interested in buying ammunition for your proton torpedoes

             The official nods, and inquires how much ammunition would you like to buy

             [Note that you currently have ${ship_ammo} and the maximum you can hold is ${ship_maxammo}, any purchases over this amount will be lost]

             *choice
                 *if (money > (cost_torpedo*1)) #One salvo of torpedoes
                    *set ship_ammo +1
                    *set money -(cost_torpedo*1)
                    *goto finish_buying_ammo

(I’m assuming after saying you are interested in buying ammo, you want it to go to a choice to select how many torpedoes to buy.)


#5

Thanks, that worked! Can’t believe I missed something so obvious and that I was looking at it for so long… Embarrassing!!!