Right. Getting something to attack you I don't know how to do myself but others do I believe. You may need to use RPG mode for that.
Turning on a light would be damned hard to script, I don't know how I would go about doing that. Perhaps setting up a teleport from an unlit room to a copy of that room only lit upon switching a switch, but that's sorta cheating, not that it matters. It does work because I've used a method like that for filling a room up with water. Match a "teleport" with a "teledest" by setting their tags to the same number. Come back to this once you've read the rest.
Anyway. While ingame, and in edit mode, press F6. The window you see there is the "cfg" editor, aka script editor. There you can write script so that mapmodels and platforms etc. do things. Instead of editing script ingame you can go to the "my_stuff\packages\base" folder. It'll be called <map_name>.cfg
There are loads of different commands you can use for the script. An understanding of the concepts of programming would make script editing so much easier. But for now I will help with the basics.
When you press F3 while a mapmodel is selected, a list of different properties pops up. The trigger type and trigger tag properties are important for scripting.
The trigger type is basically what will happen when the mapmodel is touched (e.g. will it disappear, will it only trigger the script once or every time you touch it, will a door open, will it be locked etc.). Refer to this for different trigger types and what they do:
http://sandboxgamemaker.com/platinumart ... _mapmodel_
The trigger tag is the identifier which allows it to be triggered uniquely. A nice simple example would be the locked door. Create a door and set it's trigger type to 11 and tag to 1 (which tag doesn't really matter but I'll use 1 for this). Then create a switch with trigger type 3 and the same trigger tag as the door (aka 1). When you touch the switch, it switches and the door opens. Note that the door won't open as you approach the door itself.
So far you don't need to write anything in the cfg editor. But you could do something simple as to write a message to say when the door has opened. To do that, you open the script editor (F6) and write in there:
Code: Select all
level_trigger_1 = [
echo "The door has opened."
]
level_trigger_1 is what happens when you approach a mapmodel with trigger tag 1. "echo" is basically a command which writes something up in the top left corner of the screen. Get it so far?