• Orbital Designs
  • Currrent:
  • News
  • Download
  • Discussion Forum
  • Project info:
  • About Spaceway
  • FAQ and controls
  • Add-on making
  • Vessels
  • Screenshots
  •       Add-on making

    Fact sheet about development

    Locating stuff

    Function reference

      Add-ons - Fact sheet about development

    The add-ons are written in a Pascal language dialect called Paser.
    Details about the language are better to be obtained from Pascal tutorial of your choice.

    Paser difference from pascal (subject to changes and fixes with little notice):
    -No pointers
    -No case structure
    -No enumerables
    -No variable initialization (var x:integer=0;)
    -Float without fractional part should be marked with .0 like in C++ (123.0+3.12=126.12, 123+3.12=126 or 0)
    -No units on user side
    -Open return operators (x:=y:=z:=0;)
    -No exit; operator for functions
    -No passing by var (procedure x(var y:integer);)
    -No typed constants (const x:vec=(3,5,6);)
    -Functional bias (x:=vali(i); instead of val(i,x);)
    -No forward declarations

    Module basics:
    -Program keeps it's state unless recompiled in-game. All global variables persist between calls, local ones may change.
    -Basic design is set of callbacks. There is no main "begin end.". There is a creation callback instead.
    -All modules are compiled before main menu appears.
    -creation is called at this time or at recompilation during the game. It should be assumed that there is no game when it is called.

    Debugging basics:
    -Compile errors are written to the log file and to the debug console
    -Debug console is opened up by ~ key.
    -If there were a compile error, debug console opens up automatically.
    -You can write mesasges to log/console with wr_log(s:string); call.
    -To recompile all from the game, go to Main menu->Debug->Recompile.


      Add-ons - Locating stuff

    -Vessel configs are located in data/cfg
    -Bases configs are located in data/base
    -Procedural mesh definitions are in data/blocks
    -Declarative meshes are in data/msh
    -MFD modules are in data/mfd
    -Generic includes are in data/scripts
    -Declaratie textures are in data/vestex

    For vessels and bases, the code is between :script: and :EOS: tags in their cfg files
    For MFDs the entire txt or pas file is the code.


      Add-ons - Function reference

    Types of things:
    -object, dword.
    Any vessel, base, planet, etc.
    Describes an object in game space.
    Can be -1 if no object returned by the call that should return one.
    Common notation - obj.

    -vessel, dword.
    Number of the vessel (from 0 to get_vessel_count-1).
    Used for vessel enumeration, not mutable with object.
    Common notation - ves.

    -mfd, dword.
    MFD object. Used for MFD-related calls.

    For MFDs the parameter is MFD, for vessel - VES, for bases - OBJ.

    -Creation callback. Called at Spaceway start
    procedure creation(mfd:dword);

    -MFD open callback
    procedure init(mfd:dword);

    -Button press callback
    procedure button(mfd:dword);

    -Redraw MFD callback
    procedure draw(mfd:dword);

    Common utils:
    -Write s to debug log
    procedure wr_log(s:string);
    -Translate string s to selected language
    function po(s:string):string;

    Vector utils:
    -Subtract vectors
    function subv(v1,v2:vec):vec;
    -Add vectors
    function addv(v1,v2:vec):vec;
    -Get length of vector
    function modv(v:vec):double;

    MFD utils:
    -Set MFD name
    procedure set_mfd_name(mfd:dword;name:string);
    -Set MFD button n
    procedure set_mfd_button(mfd:dword;n:integer;name:string);

    -Get width of MFD surface
    function get_mfd_width(mfd:dword):integer;
    -Get height of MFD surface
    function get_mfd_height(mfd:dword):integer;
    -Which button was pressed (works in button callback only)
    function get_pressed_button(mfd:dword):integer;
    -Get result of a system callback (works in object selection callback), returns an object
    function get_call_result(mfd:dword):dword;

    -Request an object selection menu with caption name, which will return the resulting object by calling function func
    procedure mk_vessel_callback(mfd:dword;name,func:string);

    -Write text s at x,y, with color col.
    procedure wrftxt(mfd:dword;x,y:integer;s:string;col:dword);
    -Write text s centered at x,y, with color col.
    procedure wrftxtcnt(mfd:dword;x,y:integer;s:string;col:dword);
    -Draw a filled square at x,y, sized xs,ys, with background color fill and border color border.
    procedure drsqrx(mfd:dword;x,y,xs,ys:integer;fill,border:dword);

    -Returns current vessel
    function get_focus_vessel:dword;
    -Returns vessel count
    function get_vessel_count:integer;

    Vessel control:
    -Stop rotation
    procedure killrot(ves:dword);
    -Refuel vessel
    procedure fill_vessel_fuel(ves:dword);
    -Set vessel pitch, yaw and roll rates
    procedure set_pitch_vel(ves:dword;vel:double);
    procedure set_yaw_vel(ves:dword;vel:double);
    procedure set_roll_vel(ves:dword;vel:double);

    Object tools:
    -Get object name
    function get_object_name(obj:dword):string;
    -Get object size
    function get_object_size(obj:dword):double;
    -Get mass of the object
    function get_object_mass(obj:dword):double;
    -Returns distance between objects
    function get_objects_distance(obja,objb:dword):double;
    -Get object position
    function get_object_pos(obj:dword):vec;
    -Get object velocity
    function get_object_vel(obj:dword):vec;
    -Get object galactic position
    function get_object_gps(obj:dword):vec;
    -Get object universe position
    function get_object_glp(obj:dword):vec;
    -Rotate vector v into obj frame
    function obj_global2local(obj:dword;v:vec):vec;
    -Rotate vector v from obj frame
    function obj_local2global(obj:dword;v:vec):vec;

    Vessel tools:
    -Returns vessel object
    function get_vessel_object(ves:dword):dword;
    -Returns vessel reference object
    function get_vessel_reference(ves:dword):dword;
    -Returns vessel name
    function get_vessel_name(ves:dword):string;
    -Distance between vessels
    function get_vessels_distance(ves1,ves2:dword):double;
    -Get vessel size
    function get_vessel_size(ves:dword):double;
    -Get vessel mass
    function get_vessel_mass(ves:dword):double;
    -Pitch, yaw and roll angles of the vessel
    function get_pitch_vel(ves:dword):double;
    function get_yaw_vel(ves:dword):double;
    function get_roll_vel(ves:dword):double;
    -Absolute velocity of the vessel
    function get_absolute_vel(ves:dword):double;
    -Ficused vessel pos, vel, gps, glp
    function get_focus_pos:vec;
    function get_focus_vel:vec;
    function get_focus_gps:vec;
    function get_focus_glp:vec;
    -Surface relative velocity vector
    function get_vessel_surface_vel_vec(ves:dword):vec;
    -Angle of attack, angle of slip
    function get_vessel_aoa(ves:dword):double;
    function get_vessel_bob(ves:dword):double;

    Planet tools:
    -Get atmospheric y parameter at position pos of planet obj
    function get_air_y(obj:dword;pos:vec):double;
    -Get speed of sound at position pos of planet obj
    function get_air_soundvel(obj:dword;pos:vec):double;
    -Get air pressure at position pos of planet obj
    function get_air_pressure(obj:dword;pos:vec):double;
    -Get air densty at position pos of planet obj
    function get_air_density(obj:dword;pos:vec):double;
    -Get air temperature at position pos of planet obj
    function get_air_temperature(obj:dword;pos:vec):double;
    -Get surface temperature at position pos of planet obj
    function get_surf_temperature(obj:dword;pos:vec):double;


      ADSE 0.9.1   © 2005-2015,