Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Computing with levers and floodgates  (Read 945 times)

sausage

  • Bay Watcher
    • View Profile
Computing with levers and floodgates
« on: April 24, 2009, 02:20:13 am »

I am trying to make a dungeon adventure thingamabob but I don't understand how levers work, I made a little notepad trying to explain it to myself

Quote
123 = floodgates

ABC - levers

A to 1+3
B to 2+3
C to 1+2

all close

Pull A 1+3 open A = true 2 still closed pass = false
Pull B 2 Open 1 Close?? B = true 1 now close pass = false
Pull C 1 Open C = True none closed pass = true

All open

A,B,C = true

if A and B and C = true pass = true...

I tested my theory and I found out I have no idea how this thing works

the setup for this was like this
Code: [Select]

   ########
   #ABC   #
####      #
123       #
###########

can anyone explain the theory behind this? because when I link Lever A to floodgate 1 and 3 and hit it 1 and 3 open, but when I hit B linked to 2 and 3, 3 doesnt close again... (kind of against my logic of thinking...)
Logged
Of course, why else would dwarves risk life and limb to retrive one sock during a full scale siege onslaught.
The depressing thing is that they quite often lose life and limb(s) in the process.

AncientEnemy

  • Bay Watcher
  • The Answer is always POUR MAGMA ON IT
    • View Profile
Re: Computing with levers and floodgates
« Reply #1 on: April 24, 2009, 02:37:27 am »

levers and pressure plates send distinct ON and OFF messages. a given device, when it receives a certain message, will only react one way. a door always opens on an ON message and will just remain open if it already was.

 this makes it a huge pain in the ass if you want one lever to open one thing but close another. it either requires building setups that use Raising Bridges (which react opposite to doors/floodates, ON = raised bridge (closed), or using complex water/pressure plate setups to turn a single lever throw into multiple different signals

CynicalRyan

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #2 on: April 24, 2009, 02:40:15 am »

It's Boolean logic, so works just like expected.

Wikiality on Boolean Logic

If it is tl;dr-worthy:

Levers and their components are binary. If you change the lever, you change the binary state (i.e. "on" or "off", "open" or "closed") of whatever is attached, so something that was open closes, something that was closed opens.

The effect you experience is a standard riddle of RPGs/adventures/well, anything with riddles, really. It's jsut that you get to build it.
Logged

sausage

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #3 on: April 24, 2009, 02:45:50 am »

Quote
this makes it a huge pain in the ass if you want one lever to open one thing but close another.

that is exactly what I want to do, can you help me set this up?
Logged
Of course, why else would dwarves risk life and limb to retrive one sock during a full scale siege onslaught.
The depressing thing is that they quite often lose life and limb(s) in the process.

Lesconrads

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #4 on: April 24, 2009, 05:20:15 am »

I have no experience with this, but I might give you a few hints.

Pressure plates can be activated depending on height of fluid on top.
What you want to do, is have a 2 small rooms, connected with a pump. In one is water, in the other is a pressure plate that is active on water from 0 to 0 tiles on top. Also, there needs to be some possibility for backflow when the pump is deactivated.

Original situation: Item A is "off", being linked to the leaver directly. Item B is "on", being linked to the pressureplate. The leaver is also linked to the pump or the gear assembly, powering the pump. The pump is "off"
When you pull the leaver, you send the "on" signal to Item A and to the pump. The pump moves the water on top of the pressure plate, that now sends the "off" signal to Item b.

Pull leaver again, Item A is gets it's "off" signal, pump gets it's "off" signal and the pressure plate, now being without water again (after some time, sadly) will sent the "on" signal.

profit!
Logged

AncientEnemy

  • Bay Watcher
  • The Answer is always POUR MAGMA ON IT
    • View Profile
Re: Computing with levers and floodgates
« Reply #5 on: April 24, 2009, 05:43:20 am »

Quote
this makes it a huge pain in the ass if you want one lever to open one thing but close another.

that is exactly what I want to do, can you help me set this up?

honestly, I don't think I can help with your initial setup. I'll admit im at work and only skimming it, but it seems like you want it so a lever simply acts as a toggle, and take the state of the device it's connected to into account (so pulling a given lever always changes something), and this isn't possible without more 'dwarven computing' than i've ever bothered with.

here, however, is one setup that will turn a single lever pull in to both an on and off message:

Code: [Select]
WWWWW walls
~BPFW ~water source, raising Bridge, Pressure plate 7-7, Floodgate
~BpFW pressure plate 0-6
WWWWW

don't connect it to the waterway at first (you'll need an endless (or at least very large) supply for this setup), connect the Lever to both the bridge and both the floodgates, then link your two 'alternate' devices, one to each pressure plate. now connect it to the water source. the plates will be submerged under 7/7 water, P will be ON, p will be OFF. when you throw the lever, the bridge raises and closes off the water source, and the floodgates open, allowing the plates to dip below 7/7. P turns OFF, p turns ON. another throw, the floodgates close (incidentally crushing the water on them, so they'll be dry next cycle), and the water source flows in again.

i should note however that this includes long delays, 100+ ticks for the ON messages (bridges and floodgates have a 100 tick delay, plus a few more ticks for the water to move), and 200+ for the OFF messages (in addition, pressure plates take 100 ticks to update to OFF)
« Last Edit: April 24, 2009, 05:49:35 am by AncientEnemy »
Logged

Shoku

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #6 on: April 24, 2009, 08:21:43 am »

You could pull off some degree of toggle switches with just two levers if you carefully managed the power sucked up by some gear assembles and the like such that there was only enough power for one of the switches to be on at a time.
Logged
Please get involved with my making worlds thread.

Lesconrads

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #7 on: April 24, 2009, 09:02:59 am »

To add to the above:
just the usual link to the Wiki, because that was more of a logic xor-gate instead of a logical inverter... but with a combination of water and mechanical logic, you might compute well.
« Last Edit: April 24, 2009, 09:04:34 am by Lesconrads »
Logged

sausage

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #8 on: April 24, 2009, 12:47:20 pm »

ok thanks, ill try and let you know how it goes
Logged
Of course, why else would dwarves risk life and limb to retrive one sock during a full scale siege onslaught.
The depressing thing is that they quite often lose life and limb(s) in the process.

Jurph

  • Bay Watcher
  • Minister of Belt-fed Weaponry
    • View Profile
Re: Computing with levers and floodgates
« Reply #9 on: April 24, 2009, 01:32:07 pm »

If you want to open one floodgate (or hatch, or door) and close another floodgate (or hatch or door), with the same lever, and you always want that lever to keep the two doors in opposite states, it's as simple as this:
  • Build a lever
  • Build your doors
  • Link the first door to the lever
  • Pull the lever
  • Link the second door to the lever
Logged
Dreambrother has my original hammer-shaped Great Hall.  Towerweak has taken the idea to the next level.

sausage

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #10 on: April 24, 2009, 01:37:30 pm »

thats waht i did and it didnt work
Logged
Of course, why else would dwarves risk life and limb to retrive one sock during a full scale siege onslaught.
The depressing thing is that they quite often lose life and limb(s) in the process.

Lesconrads

  • Bay Watcher
    • View Profile
Re: Computing with levers and floodgates
« Reply #11 on: April 24, 2009, 02:01:41 pm »

Wiki... read it... :P
(not wanting to sound rude! It just is very much faster than speculating and/or asking the forums :))

Just for completeness sake for anyone using the search:
Leavers, as well as pressure plates do the following.
When toggled, they send to all linked items their current status.

So leavers send "on" to everything, and "off" to everything. Thus, linking, pulling to "on", linking, pulling to "off" will lead to 2 items in the "off"-status. They don't toggle but only send their current status!
« Last Edit: April 24, 2009, 02:04:19 pm by Lesconrads »
Logged

Albedo

  • Bay Watcher
  • Menacing with spikes of curmudgeonite.
    • View Profile
Re: Computing with levers and floodgates
« Reply #12 on: April 24, 2009, 06:37:10 pm »

Correct.

Levers and their components are binary. If you change the lever, you change the binary state (i.e. "on" or "off", "open" or "closed") of whatever is attached, so something that was open closes, something that was closed opens.
If you want to open one floodgate (or hatch, or door) and close another floodgate (or hatch or door), with the same lever, and you always want that lever to keep the two doors in opposite states, it's as simple as this:
  • Build a lever
  • Build your doors
  • Link the first door to the lever
  • Pull the lever
  • Link the second door to the lever

Um... no.

These don't work like that.  Ancient Enemy & Lesconrads have it right.

If you "open" a lever, a door (or other barrier) opens.  If the door is already open, nothing happens.  Similarly with closing a lever - any open doors close, but closed doors stay closed.  Floodgates and hatches work similarly. (Note that floodgates have a delay that can create problems if using pressure plates with water or other stimulus that can "toggle" too quickly, before the floodgate can achieve it's new state.  Two (or more) signals may be sent, but only the first is read until the state has changed.)

Drawbridge-doors* work the opposite.  They raise when "open", which shuts the path.  This can be used to your advantage for computing.

(*A raised drawbridge becomes a wall, so can seal a hallway or other passage, effectively acting as a door or floodgate to seal fluid flow.)

And every lever is set up the same, visible as either open or closed depending which way it's leaning (left is closed iirc, right is open - but I wouldn't be the fortress on that. It should be obvious.)

But currently there is no barrier that toggles every time a switch is thrown regardless of its state, open or shut.

(I was installing my first bank of floodgates, my first mechanisms, managed to throw the lever (to "open") before attaching any floodgates to it.  They were then build, and the dorf predictably sealed himself on the wrong side.  I then connected a mechanism, and threw the lever (to "closed" - but I didn't realize this yet) to release him - nothing happened.

There was mixed frustration and panic, and only some time later I figured out what had happened. 

Levers don't toggle the barriers they are connected to.  They send them either an open or close signal, according to the state of the lever, and they respond accordingly.
« Last Edit: April 24, 2009, 06:39:25 pm by Albedo »
Logged

AncientEnemy

  • Bay Watcher
  • The Answer is always POUR MAGMA ON IT
    • View Profile
Re: Computing with levers and floodgates
« Reply #13 on: April 24, 2009, 06:49:22 pm »

I'd just like to emphasize once again the wonderfulness in this regard of Raising Bridges when used as doors: they have the 'opposite' settings as regular doors and floodgates.

On signal to a door or floodgate: Open
On signal to a raising bridge: Closed (no more bridge, becomes a wall)

this can be used to circumvent the 'toggle' issue in many devices; it's what runs both my repeater and 'signal-splitting' designs.

Redhades

  • Bay Watcher
  • That boy needs therapy
    • View Profile
    • My Linkedin.com profile is all bout me
Re: Computing with levers and floodgates
« Reply #14 on: April 28, 2009, 06:56:31 pm »

Even if I'm a bit of a newb here, I'll go ahead an argue.

I had this problem on the weekend, with one lever an two floodgates side-by-side.
Each time that I had the lever pulled on or off, one floodgate was closing while the other opened.

At first I had the lever on a "Pull the lever" job set to Repeat, so I though it was just a difference of delay between the two floodgates. So then I set up the Pull job manually each time, waiting a little while before giving it another Pull. So I saw that those two floodgates really did have a toggle thing going on.

I wanted the two opening and closing at the same time, so I removed them, rebuilt them, and relinked them, and now they don't toggle anymore. They are both opening and closing together in perfect sync.

I'll see if I can get them to do it again. From what I remember, I set the lever with three tasks all in this same stack:
- Link to a floodgate
- Link to a floodgate
- Pull the lever

I wonder if it's a issue where my mechanic finished the second link right onto the lever and sort-of pulled it at the same time.
Logged