Omnimaga
General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Builderboy on October 23, 2010, 06:35:00 pm
-
So i just wanted a thread to talk about the scripting engine i wrote for Nightmare, i call it Nscript because of Nightmare script :P 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.
-
Wow looks pretty cool :D so people could make their own games with this engine when you are done with it?
-
Possibly, the engine is quite specific to Nightmare right now. Like commands like TurnFlashlightOff, or GiveFlashlight :P but it could definitely be modified for top down games. Although horror would definitely be its specialty.
-
Ah ok sweet :)
-
And it cant do things like loops or conditionals, so that makes it a bit more simple. Its definitely very specific to nightmare ^^
-
lol, when I saw this I thought it a nspire scripting language XD
pretty good tho, keep it up :)
-
lol, when I saw this I thought it a nspire scripting language XD
pretty good tho, keep it up :)
^this. ;)
-
Nice! Someone should port Blinded by the Dark to Greenfoot :D
-
/me tries to shake the idea of writing a complex scripting engine out of his head
-
Er... necropost? ANyway I wonder what software did that require...
-
Lol necropost. It actually required no extra software, as the compiler is written in java directly into my game, and the scripts themselves are just text files.
-
Ah ok, well I was wondering more if you ever released that script or something. Also with all the Nspire stuff going on when I see this thread name I always think it's a new TI-Nspire project. :P