racer home

Onyx Tutorial - Hello World

 

Home A simple start.


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

Introduction

This is the minimum application for Onyx. It is typical for any language to have a 'Hello, World' example which shows the minimal amount of work to get something done.

Onyx comes in 2 parts; Onyx outside of Racer (the 'core') and Onyx inside Racer. The external variant may be useful sometimes to use Onyx as a sort of BASIC, but then with a C++-like syntax. Racer comes with onyx_run.exe, which can be used to run Onyx scripts (that have no link to Racer) as is, in a command prompt. In Racer itself, there is the 'run' command which compiles & runs Onyx scripts (.oxs). For this to work, the script must be placed in Racer's data/scripts/onyx directory.

Let's use onyx_run to run the following programs (just copy & paste to data/scripts/onyx/helloworld.oxs):

void main()
{
  echo("Hello world");
}

Hello World in Racer

When inside Racer, you want to be able to use the Racer environment for more control. The typical Hello World app will look like this:

#include "racer.oxs"

void main()
{
  echo("Hello world");
}

The first line will include a number of functions that Racer provides; things like obtaining the current simulation time, getting the framerate and such.

The next line will probably look familiar; it just outputs 'Hello world' to the console. Racer intercepts echoes and passes them on to the console.

 


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated July 24, 2013 )