Page 1 of 1

Switches controlling Elevators and Platforms

Posted: March 24th, 2011, 6:15 pm
by CyberxNeku
Hello XD when i was first starting platinum arts I had trouble finding good tutorials on making an elevator or platform entity move according to a switch. So i decided to make one my self :mrgreen:

- First off the difference between elevators and platforms are, elevators move up and down and platforms move side to side
- Both elevator and platform entities are controled with the "platform X Y" command, where X is the trigger tag and Y is the trigger state.
For the switch, you can use a variety of trigger types that will yeild drifferent results. A good reference to these would be http://sandboxgamemaker.com/platinumart ... _mapmodel_
- I use the switch mapmodel as an example but you can really use any mapmodel you want ;) you can even trigger the platforms with keys, that when pick up (using trigger types 12 or 13) move the elevator or platfom.
- Trigger tag # are associated with level_trigger_#. I believe elevator and platform tags have nothing to do with the "level_trigger_#" and only apply to the "platform # [state#]" so you can have a switch with triger tag 1 and also have a platform with tag 1, and the two will be unrelated.
- Also i think platforms and elevators are not availible in RPG mode. I'm doing this all in FPS mode, so if these examples don't work that might be why O__O
- all codes are put into mapname.cfg

First example: a switch that can only be touched once will move an elevator
you need:
the switch mapmodel ( trigger tag 1, trigger type 9 )
an elevator entity ( tag 1 )

Code: Select all

    level_trigger_1 = [
        platform 1 1
        echo "the elevator rises"
    ]
This sould make the elevator rise when the switch is touched for the first time, touching it again does nothing. The echo is just for fun XD. You can also make the elevator lower by replacing "platform 1 1" with "platform 1 -1". You can also make the platform rise and then stop by coding

Code: Select all

    level_trigger_1 = [
        platform 1 1
        sleep 5000 [
        platform 1 0
        ]
    ]
The elevator will rise for 5000 miliseconds ( 5 seconds ) at whatever speed you gave and stop after touching the switch.

Second example: A switch that toggles moves an elevator up and down
you need:
a switch mapmodel ( trigger tag 2, trigger type 8 or 7 )
an elevator entity ( tag 2 )

Code: Select all

    level_trigger_2 = [
        if (= $triggerstate 1) [
            platform 2 1
            echo "elevator rises"
        ] [
            platform 2 -1
            echo "elevator lowers"
        ]
    ]
A trigger type of 7 or 8 toggles between trigger states 0 and 1. When the switch is touched it toggles to trigger state 1 and rises the elevator according to the "if" statement. When the switch is touched again, it toggles to trigger state 0 and lowers the elevator. You can make the switch do a variety of things like rise and stop the elevator, just change the "platform X Y" command to whatever you see fit XD. It would be awsome if platinum arts had a switch that could toggle between 3 states so you could lower, rise and stop the elevator, but they don't as of 2.6.1 ( as far as i know anyway ) If you want instead of using the "$triggerstate" value that applies to the level_trigger_# entity you can use your own make up value for example

Code: Select all

swt = 0

    level_trigger_2 = [
        if (= $swt 0) [
             platform 2 1
             echo "elevator rises"
             swt = 1
        ] [
            platform 2 -1
            echo "elevator lowers"
            swt = 0
        ]
    ]
the switch is still a trigger type of 8 or 7. The value "swt" was made up and can be anything like "Bac0n" or "cheese" just make sure whatever you put down stays consistent throught the code.

I set up these codes so you can put both example 1 and 2 in the same map for testing and whatnot. I hope this tutorial helps, and if im wrong on any of this ,since im still learning myself, do tell me XD

Re: Switches controling Elevators and Platforms

Posted: March 25th, 2011, 10:28 am
by Runescapedj
Looks good, maybe you can add it to the wiki?
http://sandboxgamemaker.com/wiki/index. ... =Main_Page

Re: Switches controlling Elevators and Platforms

Posted: March 25th, 2011, 3:05 pm
by CyberxNeku
thanks but I don't think I have rights to, let alone permission XD the license doesn't allow edits by everyone o.o but I don't really know much about that stuff anyway :P

Re: Switches controlling Elevators and Platforms

Posted: March 25th, 2011, 6:40 pm
by chocolatepie33
just go ahead and add it. Or do you want someone else to do it for you?

Re: Switches controlling Elevators and Platforms

Posted: March 25th, 2011, 7:11 pm
by CyberxNeku
Maybe someone else should do it, I tried editing in tutorials on a page that matched my tut but i wasn't allowed. Maybe im just doing it wrong, I never really done something like that before XD I know im a noob

Re: Switches controlling Elevators and Platforms

Posted: March 25th, 2011, 7:16 pm
by chocolatepie33
I'll do it, then... And fix a couple of errors (spelling)

EDIT: here it is: http://sandboxgamemaker.com/wiki/index. ... /platforms

Re: Switches controlling Elevators and Platforms

Posted: March 27th, 2011, 2:41 pm
by CyberxNeku
Thanks for doing that XD I know I'm not the greatest in spelling :P

Re: Switches controlling Elevators and Platforms

Posted: March 27th, 2011, 4:04 pm
by chocolatepie33
Yeah, don't worry, we all do that occasionally.

You're welcome.