Difference between revisions of "RogueScript"

From RogueBasin
Jump to navigation Jump to search
m
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Description ==
== Description ==


RogueScript is a proposed interpreted language with C style syntax. It will be based loosely on NWScript. It should be noted, however, that this language is not intended to be used in development of an engine, but as a means to control roguelike objects within a user-made game world (created with a game creation system).
RogueScript is a proposed interpreted language with C style syntax. It should be noted that this language is not intended to be used in development of an engine, but as a means to control roguelike objects within a user-made game world (created with a game creation system).


== Features ==
== Features ==


* C syntax
* C style syntax
* simple, yet powerful scripting (without arrays, structs, or pointers)
* table type (but no array type)
* dynamic typing
* first class functions
* easy interaction with game world things
* closures
* basic types (such as bool, undefined, float, int, string)
* dynamic typing with javascript style coercion for '==' operator
* basic types (such as bool, null, float, int, string, thing_ref, closure, function_ref)
* thing reference for passing around handles on game world objects
* extensive library of API functions
* reasonable speed
* reasonable speed


== Events ==
== Hello World program ==


Most game world objects can have scripts attached. Script functions are attached to various events.
(Note: there is no main function. Several function names are associated with events. The 'begin' event occurs at the start of the game. It gets called only once.)


* turn
     event begin()
* key_press
* give
* throw
* throw_hit
* inter-use (use nearby object)
* intra-use (use item from inventory)
* hover
* touch
* pick_up
* drop
* quaff
* eat
* target
* inventory
* kick
* apply
* look
* chat
* combine
 
== Example ==
 
     begin()
     {
     {
         log("Hello World");
         lib::notation("Hello World!");
     }
     }
   
    use()
    {
        rDoor = GetOwner();
       
        if (IsObjectRef(rDoor))
        {
            iObs = GetObjectProp(rDoor, OBJECT_PROP_STATUS);
           
            if (iObs == DOOR_STATUS_OPEN)
            {
                SetObjectProp(rDoor, OBJECT_PROP_STATUS, DOOR_STATUS_CLOSE);
                SetObjectProp(rDoor, OBJECT_PROP_OBSTRUCT, 1);
                SetObjectProp(rDoor, OBJECT_PROP_GLYPH, '+');
            }
            else if (iObs == DOOR_STATUS_CLOSE)
            {
                SetObjectProp(rDoor, OBJECT_PROP_STATUS, DOOR_STATUS_OPEN);
                SetObjectProp(rDoor, OBJECT_PROP_OBSTRUCT, 0);
                SetObjectProp(rDoor, OBJECT_PROP_GLYPH, '/');
            }


            return 1; /* override normal door behaviour */
[[Category:Developing]]
        }
       
        return 0;
    }

Latest revision as of 20:19, 1 November 2012

Description

RogueScript is a proposed interpreted language with C style syntax. It should be noted that this language is not intended to be used in development of an engine, but as a means to control roguelike objects within a user-made game world (created with a game creation system).

Features

  • C style syntax
  • table type (but no array type)
  • first class functions
  • closures
  • dynamic typing with javascript style coercion for '==' operator
  • basic types (such as bool, null, float, int, string, thing_ref, closure, function_ref)
  • thing reference for passing around handles on game world objects
  • extensive library of API functions
  • reasonable speed

Hello World program

(Note: there is no main function. Several function names are associated with events. The 'begin' event occurs at the start of the game. It gets called only once.)

   event begin()
   {
       lib::notation("Hello World!");
   }