reset a counter wall object

Links to all custom dungeons. Also discussions about custom dungeons: tips and tricks, questions, ideas, etc.
Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
jahmiann
Artisan
Posts: 195
Joined: Fri May 09, 2014 7:15 pm

reset a counter wall object

Post by jahmiann »

Hi

Is there a way to set at 0 the count of a counter_wall_object ?

i made a puzzle that increment and decrement some counters, i want to create a switch to reset the puzzle.

My problem is:
- I cannot known the current count of counter_wall_object, because i cannot know what way has been take by the party. By the way i know the number of decrement to return at 0.

Regards
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: reset a counter wall object

Post by terkio »

In RTC, I doubt there is a direct way to reset a counter.

There is a work around to reset a counter which has a positive value. The logic is: If cnt > 0 then decrement cnt.
Use a conditional relay with the condition 'counter value' greater than 0. Let this relay activate itselft and the counter.
Add a 'reset' switch to activate the relay. This works. ( activating a counter: Decerments )

For some odd reason a similar solution does not work to reset a counter which has a negative value. The logic is: If cnt < 0 then increment cnt.
I tried the same medecine as above with an additional relay to change the activate into a deactivate to the counter. ( deactivating a counter: Increments ).
A had a crash. Then added a delay, no crash but doesn' t stop at 0 it overshoots at 1. Then offset the condition, 'counter value' less than -1. Then it almost works, it stops at 0, but....from -1 nothing happens.

For the moment, I think RTC is junk. I can spend hours on such ridiculous programming.

I hope, I am wrong, and there is an easy solution for you.
Edit. I am happy, I was wrong: The clean solution is with an ACTION. There is an action to set a counter.
Last edited by terkio on Sat Jun 07, 2014 2:09 pm, edited 1 time in total.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
Chaos-Shaman
High Lord
Posts: 2642
Joined: Wed May 03, 2006 7:26 pm
Location: The Gates of Hell

Re: reset a counter wall object

Post by Chaos-Shaman »

hmmm, the relays are used to check the value of the counter. you need specific relays that react to the value you seek.

relay 1
Parameter 1 - so the relay value item would be the name of the cloned counter.... say you call it - westcounter
Parameter 2 - so the number value is equal to (value you want) say 2

there is a - counter set to zero action as well or what ever value you want

when it hits count 2 it will be west... fool with it
Last edited by Chaos-Shaman on Sat Jun 07, 2014 1:18 pm, edited 1 time in total.
keep your gor coin handy
User avatar
Chaos-Shaman
High Lord
Posts: 2642
Joined: Wed May 03, 2006 7:26 pm
Location: The Gates of Hell

Re: reset a counter wall object

Post by Chaos-Shaman »

I have never experienced that problem terkio, at any time the counter can be set, it does not even have to go below zero, that's up tot he programmer but I do use negative values and it works, can you show me an example, i'll poke around it. there is a way to set the counter in the actions, it's called, COUNTER SET, and I'd be nowhere without it so I guess I'd say that you may have missed this one. the counter works exactly as it should, it counts and can be reset, negative values work.
keep your gor coin handy
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: reset a counter wall object

Post by terkio »

Forget it.
I found how to make it work in all cases.
It does reset ( go to 0 ) from any value, positive or negative.
It takes 3 relays. At last it works, but there is defenitly irrationnal stuff in the relay behavior.

The clean solution is with the ACTION to set counters.
Not so clean.
As far as I understand, it will reset ALL counters in the dungeon. ( I see nothing to address ( point at ) a given counter ).
So in case you do not want to reset all but some of the counters....another work around is to CLONE counters. Cloning will enable you to have different sets of counters, so an action can be dedicated to a given set of counter(s), not disturbing other counters.

TY jahmiann:
Solution with 3 relays: http://twinfalls.free.fr/Walltext.txt
Solution with 1 action: http://twinfalls.free.fr/Walltext2.txt
Extra: The scroll in these is a GPS.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
jahmiann
Artisan
Posts: 195
Joined: Fri May 09, 2014 7:15 pm

Re: reset a counter wall object

Post by jahmiann »

Hi

I tested the both samples.

The second is more simple but the range of ACTION_ITEM item is to large. It reset all the counters of the level (i have other counter in the same level not link with this puzzle).

The first sample is good for me, i's quite tricky but i will use the one for my dungeon.

Thx
User avatar
Chaos-Shaman
High Lord
Posts: 2642
Joined: Wed May 03, 2006 7:26 pm
Location: The Gates of Hell

Re: reset a counter wall object

Post by Chaos-Shaman »

As far as I understand, it will reset ALL counters in the dungeon. ( I see nothing to address ( point at ) a given counter ).
terks, if it is a cloned relay it won't reset the normal counter. I see what you mean now, of course if it is not cloned it will reset them all.

that's great you found a way jahmiann, if you need any more help just let us know.
keep your gor coin handy
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: reset a counter wall object

Post by terkio »

Here is a third example with a cloned counter.

Solution with 1 action on a cloned counter: http://twinfalls.free.fr/Walltext3.txt
The intention is to reset the cloned counter without any change to other counters.

To create a cloned counter. In RTCeditor, see the main menu, use: Ressources/Create New Objects.

The 3 relays solution is more powerful.
It gives a way to load a counter with the value of another counter
Actualy, it gives a solution to load a counter with the value of various stuff.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
User avatar
terkio
Mon Master
Posts: 937
Joined: Tue Jul 10, 2012 8:24 pm

Re: reset a counter wall object

Post by terkio »

Solution with 3 relays: http://twinfalls.free.fr/Walltext.txt
This does work. But there is a trap to copy this mechanism, that can waste a hell of time.
In the relay there are up to 8 targets. One can think the order of the targets does not matter. This is not true in this example.

This example uses 2 self actvating relays. Such a relay has 2 targets: one target to itself and one target to the counter ( directly or via the third relay ).
The target to the counter must be declared before the target to itself.

In case the target to itself is first................This mechanism does not work anymore.
With zero delay, it crashes.
With some delay like 6, you see the count go to zero, but......it overshoots the 0.
From a positive count, you'll see ......, 3, 2, 1, 0, -1.
From a negative count, you'll see..... , -3, -2, -1, 0, 1.

You can play with the example to check about this peculiar behavior.

A miscellaeneous point.
Do not wonder about the condition in the third relay. It is irrelevant; No condition is perfecly fine ( 1 == 1 ). The condition came from changes where it happened to work.
"You can be on the right track and still get hit by a train!" Alfred E. Neuman
Post Reply