Little help with code again


#1

I have five var that are set true. As the player does each action within the choice it is turned false. So how do I set the 6th option to true once all five have turn false. I can do this but being a none programmer it would be complex and long. I am trying to keep the code small as possible. Thanks.

*Edit
So it would look like


*choice
 *if (option1) #Player choice
  *set option 1 false
  *goto somewhere
 *if (option2) #Player choice
  *set option2 false
  *goto somewhere
 *if (option3) #Player choice
  *set option3 false
  *goto somewhere
 *if (option4) #Player choice
  *set option4 false
  *goto somewhere
 *if (option5) #Player choice
  *set option5 false
  *goto somewhere
 *comment Once all five options have been set to false the sixth option is set to true
 *if (option6) Players choice
   *goto somewhere



#2

I would do something like this.


*temp option6 0

*choice
  *if (option1) #Player choice
    *set option 1 false
    *set option6 +1
    *goto somewhere
  *if (option2) #Player choice
    *set option2 false
    *set option6 +1
    *goto somewhere
  *if (option3) #Player choice
    *set option3 false
    *set option6 +1
    *goto somewhere
  *if (option4) #Player choice
    *set option4 false
    *set option6 +1
    *goto somewhere
  *if (option5) #Player choice
    *set option5 false
    *set option6 +1
    *goto somewhere
 *comment Once all five options have been set to false the sixth option is set to true
  *if (option6) = 5
    Players choice
    *goto somewhere


#3

*temp tick 0
*label somewhere
*choice
 *if (option1) #Player choice
  *set option 1 false
  *set tick +1
  *goto somewhere
 *if (option2) #Player choice
  *set option2 false
  *set tick +1
  *goto somewhere
 *if (option3) #Player choice
  *set option3 false
  *set tick +1
  *goto somewhere
 *if (option4) #Player choice
  *set option4 false
  *set tick +1
  *goto somewhere
 *if (option5) #Player choice
  *set option5 false
  *set tick +1
  *goto somewhere
 *comment Once all five options have been set to false the sixth option is set to true
 *if (option6 and (tick > 4)) Players choice
   *goto somewhere_else

Edit: ninja’d!


#4

@fantom and @Havenstone
This what I needed thanks. :smiley: ^:)^


#5

I think it’s funny that we both came up with essentially the same idea. :slight_smile:


#6

I would have had a gosub or two do the checks and I knew there would a far simpler way. :slight_smile:

@fantom
Great minds think alike lol.


#7

Why put in variables for each action, when you can just use *hide_reuse?

The ‘tick’ method is probably the best option for the specific question, though.


#8

@Dominic
I have several groups of choice sections on the page and was having problem with the hide_reuse working consistenly. As they all started out with hide_reuse. Settling them All T or F resolved the problem. The tick worked well for what I was aiming for.


#9

Seems I have hit a snag and for the life of me cannot see the problem
The error:
line 161 Invalid expression, couldn’t extract another token
Now Mistress or Master is set true before reaching this point.


147 *label step_4
148 I know I am nothing more then a loathsome toad and you care not for my thoughts. But ${t_call} that is an awe inspiring name.
149 *choice
150  #Slap ${imp}
151   *set slapsilly +1
152   Thank so kindly ${t_call} for putting me in my place. I would loose my way if it were not for your most forcefull blows to remind me I am only a worm.
153   *line_break
154   *goto step_5
155  #Your strange little creature.
156   As you say ${t_call}.
157   *goto step_5
158  *if (mistress) #You're most kind
159   Praise is for the weak, shall we keep focused.
160   *goto step_5
<b>161 *if (master} #You're a fairly smart little toad</b> 
162   Ow yes Master I am.
163   *goto step_5


#10

Check your brackets… ) }


#11

lol Thanks @andymwhy Had me stomped. As you get older your eyes get weaker. Teach me to work without my specs.


#12

Trying to recall, I need to set a statement if the var is false. So the message will read ‘You currently have no skills’. Of course once the var is set true I know to:


*if (var)
 Current skill
 *goto somewhere

Thanks guys/gals for the help.


#13

I resolved what I needed.

Quick question on quicktest
I get the following error

QUICKTEST FAILED
TypeError: Object # has no method ‘toLowerCase’

Not sure how to resolve this. Any ideas?


#14

Ok so I thought I would bypass the problem by adding

*input_text user
*comment convert input to lowercase for easier matching:
*script temps.ans = temps.ans.toLowerCase();

So no I get a new error

QUICKTEST FAILED
TypeError: Property ‘onerror’ of object [object global] is not a function

I have done some searching but I have no clue how to resolve this.


#15

As a mod I feel I must quote:

7. This forum is not dedicated to JavaScript. Choice of Games does not support the functions of *script. Moreover, this is not the place to post questions about JavaScript.

But since this particular one is quite easy to resolve I will say that there is no root level/global “temps” object in choicescript, its kept inside the scene/stats object, so *script this.temps.nameoftempvar should work.


#16

@CJW Thanks. I was just trying to figure out how to get around the quicktest error, did not dawn on me this question my have been better in pm. Thanks again.


#17

So I tried this and came back to the first error
QUICKTEST FAILED
TypeError: Object # has no method ‘toLowerCase’

I removed all *script commands, only had a few
Then commented out the only input_text in the game and made sure it would goto the next scene

Yet when I run quicktest I still get
QUICKTEST FAILED
TypeError: Object # has no method ‘toLowerCase’

Any thoughts on what might be causing it, or what I may have screwed up?


#18

No clue, could you dump your code here or send me a link/zip to/of the game via PM?


#19

Give me a second and I will up load a zipfile of the scene files to a folder and give you the link. A lot of pages and quicktest does not identify which page the error is falling.


#20

PM you on the download. Thanks again.