I designed these 2 chips at the same time and to save forum readers I combined these two scripts into one post.
First I have the Dual Input Counter:
Code:
N@Dual Input Counter
I@Pos Neg Set Reset Rate Min Max
O@Out
LIMIT=Max>Min
!Rate -> Rate=1;
Pos -> Out += Rate;
Neg -> Out += Rate*-1;
Set -> Out=Set;
Reset -> Out=0;
Out < Min & LIMIT -> Out = Min;
Out > Max & LIMIT -> Out = Max;
Pretty much what this does is effectively keep an active counter with some customizable controls. I will explain input by input:
Pos -> This is the trigger to increment the counter.
Neg -> This is the trigger to decrement the counter.
Set -> This is a special trigger to set the value to what you desire.
Reset -> Simply triggers the counter to zero.
Rate -> This is a value to tell the chip at what rate to change.
Min -> The minimum floor for the counter if the limit is activated.
Max -> The maximum ceiling for the counter if the limit is activated.
There is no rate of zero: so if the chip sees a rate of zero it defaults it to one.
If the Maximum is greater than the Minimum then the limit is activated. So that means if you do not designate a Min and Max both are zero so there is no limit. If you designate a MAX of 10 and no Min then the chip reads the max greater than the min and only allows values between 0 and 10 even if a set, pos, neg, or reset triggers it out of bounds: it will automatically set it to the corresponding min or max.
Thats chip number one and works great with my beloved pod controls. Now with the next one:
The Dual Input 10 Port Data Table:
Code:
N@10 Port Data Table
I@Pos Neg Set Reset Max Data0 Data1 Data2 Data3 Data4 Data5 Data6 Data7 Data8 Data9
O@Index Output
!Max -> Max=9;
Index & Neg -> Index += -1;
Index < Max & Pos -> Index += 1;
Set -> Index=Set;
Reset -> Index=0;
!Index -> Output=Data0;
Index==1 -> Output=Data1;
Index==2 -> Output=Data2;
Index==3 -> Output=Data3;
Index==4 -> Output=Data4;
Index==5 -> Output=Data5;
Index==6 -> Output=Data6;
Index==7 -> Output=Data7;
Index==8 -> Output=Data8;
Index==9 -> Output=Data9;
Very similar to the other chip this is is more confined and has a considerable less amout of 'play' when it comes to the counting range. The range is only from 0-9 but each "index" has a special "data" port assigned to it. I'll first explain the inputs and outputs:
Pos -> This is the trigger to increment the index.
Neg -> This is the trigger to decrement the index.
Set -> This is a special trigger to set the index to what you desire.
Reset -> Simply triggers the index to zero.
Max -> The maximum ceiling for the index when using the Pos trigger.
Data0-Data9 -> The corresponding outputs you desire to link with their index.
Index -> The index the datatable is pointing at.
Output -> The corresponding data for the index from the data ports.
The absense of Min and Rate are not a mistake, simply they would rarely be used.
The chip defaults the Max to 9 if it reads 0. The Max is only for the positive increment trigger. This is intentional (maybe for a secret level on an elevator only accessable if you type in the right code .. just a thought).
whew! I know it sounds difficult but once you use it once you'll understand it.
If this really boggles ya I'll help you out. I have an advanced duplicator save of a mean etch-o-sketch using 2 dual input counters, 2 constants, a memory toggle chip, a digital screen, a small tv screen, an indicator, and a pod controller. If you download the save you will need PHX, and wiremod with the expression chip. Also theres a small bug: for some reason you have to "re-link" the pod controls to use it. Also save as.. when saving .. its a text file
(sorry no screenshot yet)
Bookmarks