Counter increments by two?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Counter increments by two?

Post by Isaac »

I have a script linked to a button. Press the button, and a counter increments.
If the counter value is equal or greater than 9, it resets (to zero). The initial value is zero.

This is my script

Code: Select all

function activate()
	counter_1:increment()
	CellNum = counter_1:getValue()
	print(CellNum)
   if CellNum>=9 then counter_1:reset() end
end
When I press the button the script prints the counter value to the screen.

First press = 1
Second press = 3
Third press = 5 (and so on)

After the counter resets the value to zero, the first press after this prints the value as 2 [then 4, 6, 8, 10]
After the counter [again] resets (when the value is 9 or greater), the subsequent values are always the even ones, never the odd.

What's going on here?
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: Counter increments by two?

Post by antti »

What connectors do you have on the button?

If you have a connector on the button that increments the counter, the increment will happen twice since the script does it as well.
Steven Seagal of gaming industry
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Counter increments by two?

Post by Isaac »

antti wrote:What connectors do you have on the button?

If you have a connector on the button that increments the counter, the increment will happen twice since the script does it as well.
Ah ha; yes there is a connector.

When I comment out the counter_1:increment() line, it then works predictably.

Thank you.

** I see now that the button connector lists it's action as Increment; I missed or forgot about that. :oops:

Next time I'll not be so quick to post, and double or triple check things before hand.
Post Reply