A little help with some switches

So i plan on have switches in my second game that i am trying to finish. So just to get an idea. There will be a switch in one room, that will open a door in another. Now I know to use a boolean to control that. My question is what about when there are multiple switches on one level?

I dont have code to screenshot, but like i said i understand how to activate one.

Game lvl att
Boolean: switchactive false

Switch actor
When switch is touched, change att switchactive to true

Door actor
If switchactive is true open door.

Now what if there are more switches. Do I have to have more game lvl attributes? like switchactive 2, 3, 4, etc...

I plan on having no more than 6 switches on some levels. Thanks for any help or suggestions


  • jamie_cjamie_c ImagineLabs.rocks Member, BASIC Posts: 5,659

    You could use multiple Game Level Attributes, one for each door/switch combination or you might consider building a Table to keep track of which doors should be locked/unlocked.

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2016

    Yep, like @jamie_c said, just make a bunch of attributes:

    • Main Door Switch
    • Dungeon entrance Switch
    • Bedroom Door Switch
    • Kitchen Door Switch
    • Basement Door Switch

    etc etc . . . . .

    Do you know what would be really neat with GameSalad, the ability to label Boolean values.

    At the moment you can use either [1 or 0] or [true or false], but it would be great if we could change the 'true and false' labels to suit our actor / game.

    For example if you were opening and closing a bunch of doors you could change [true or false] to [Open or Closed] for the door actors . . .

    So your Change Attribute behaviour would read: Change Main Door Switch - to - Open . . . rather than Change Main Door Switch - to - true.

    Or Change Direction - to - Up . . . rather than Change Direction - to - 1

    You could have values like . . . On or Off . . . Locked or Unlocked . . . Alive or Dead . . . Up or Down . . . Left or Right . . . Win or Lose . . . Open or Closed . . . etc etc.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,914

    I never use booleans. I always just step integers. This give me more flexibility going forward and also gives me a neutral state if I want it. Plus you avoid the cross coding with a stepped integer and slims the number of attributes.

  • GamingtilDawnGamingtilDawn Member Posts: 104

    Thank you all for your help. I have an idea now of where to start. :smiley:

  • GnarlyGnarly canadaMember Posts: 840

    Custom booleans is brilliant. That would help beginners with their logic immensely.

    Will never happen.

Sign In or Register to comment.