I'm working out the details of Lithoclast's (My upcoming game engine, due in about 2 years... ) scripting language. I'd like to know if what I have so far seems reasonable to the dedicated game developers here.
The language - which I don't have a name for yet - has some C influence, but it uses reverse-polish notation rather than the algebraic notation most languages use. The reason for this is mostly for speed, but also for simplicity of implementation. (Particularly doing away with bothersome algebraic oddities like parenthesis and operator precedence while not giving up the ability to do things that would require them. )
If you don't know how RPN works: (url="http://"http://www.wikipedia.org/wiki/Reverse_Polish_Notation")http://www.wikipedia...Polish_Notation(/url)
The little bitty script below does something simple - puts the characters the player designed for their party (The number of which is up to the developer) into the starting world of the game. Please tell me you think you could handle it... (With a manual, of course...)
The // and open and close comments, { and } designate code blocks, and a ' tells the interpreter to store the top value on the stack in the variable marked with the '.
Commands have colons in them, so the interpreting can be much more efficient.
Hopefully the UBB won't mess this code all up...
---------------
// A Simple Game Initialization Script
Š 4/2003 Bryce Schroeder. Run only when there is a new game started.
The invisible construction object on the inital map we'll use for the coordinates is ID 42.
Remember, the scripting language is in reverse polish notation,
so that is why it may look funny to you. It is also somewhat whitespace-sensitive.
# 42 = Target_Object
// Defines a constant by replacing the text to the right to the text on the left in the code at compile-time.
# get:varible:int 1 . = Count
# set:varible:int 1 . = Count'
// Variables for scripts are all identified numerically, but since referring to them as 'get:varible:int 1' or
whatever would be confusing, you can give them names in the same fashion as constants are defined. At no
time should you think that the varible is actualy called by that name, as the compiler just subsitutes the original
text back in when in runs.
main
{
// Semicolons separate multiple augments, periods end a series of augments.
control:loop:for 0 Count'; Count get:init:CTotal <=; 1 Count + Count' . // For Loop
{
get (img)http://www.AmbrosiaSW.com/webboard/redface.gif(/img)bjects:location:xyz Target_Object .
// Places the X, Y and Z coordinates on the stack
Count +
// Puts the current value of Count on the stack and then adds it to the previous number - our Z coordinate - and then puts the increased Z on the stack.
set:characters:location:xyz get:init:CMaker Count . .
// Reads the top three numbers off the stack - the ones we just put there - and sets the position of the character identified by CMaker to them.
} // Closes for loop
} // Closes main function
// The End result here will be our new characters lined up in a row along the Z axis next to our construction
object we used for positioning. It could do it in a fancier way, putting the characters in a square formation or
checking for walls in the way, but it doesn't (img)http://www.AmbrosiaSW.com/webboard/smile.gif(/img)
------------------
Programming is an art form that fights back.
- Unknown
Where do you want to (url="http://"http://www.macclassics.com/cythera/tricks/rJade.htm")teleport(/url) today?
(edit) fixed formating to apease celchu.
(edits) Urrg! Formatting woes...
(edit) Urrg! Syntax error!...
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-08-2003).)
(This message has been edited by Bryce (edited 04-09-2003).)