So i just wanted a thread to talk about the scripting engine i wrote for Nightmare, i call it Nscript because of Nightmare script
Its a very simple scripting language with simple and easy to understand syntax. For example to create an object:
#ActionActor #Global Sound background_loop1 ambiance.wav
#ActionActor specifies the type of the object. Currently it can only be of type ActionActor (any object ingame) or Trigger (triggers events).
#Global means that this object can be used by all scripts
Sound means that it is a Sound object
background_loop1 is the name of the object
ambiance.wav is the input into creating the object, in this case it tell the object to use the sound file ambiance.wav
then i can do things like
background_loop1 play
background_loop1 pause
background_loop1 stop
background_loop1 playLoop
I can also create objects that are visually present in the world
#ActionActor StaticImage flashlight flashlight.bmp
creates an Image object with no special properties with the image of a flashlight taken from file flashlight.bmp. I can then use some special object commands like:
flashlight addToWorld 50 50 puts the flashlight into the world at coordinates 50,50
flashlight move 20 20 10 moves the flashlight 20 units to the right and 20 units down in the space of 10 frames
Now this is all fine and dandy, but how do you do those cool things like closing a door when you get close to it? Well that involves a new type of object called a Trigger object. Here is how you create one:
#Trigger TriggerRect door_close 50 50 80 80
this command creates a TriggerRect object. This object triggers when the player is within the region defined by 50,50 and 80,80. For the trigger to activate code, you need an entrance point.
If door_close
door_1 close
Sleep
the IF tells the trigger that "when the player comes into your area of 50,50 80,80, start this code right here!". It then closes the door and goes back to sleep. Going to sleep just means that the script isnt doing anything. The only way to wake the script up is for one of its triggers to wake it up and start some code. So this is our final script example
#ActionActor Door door_1 unlocked open 0
#Trigger TriggerRect door_close 50 50 80 80
door_1 addToWorld 50 60
Sleep
If door_close
door_1 close
door_1 lock
Terminate
this script creates a door and a trigger, and when the player walks by the door, the script closes it, locks it, and then stops executing.