View unanswered posts | View active topics It is currently Thu Mar 28, 2024 7:42 pm



Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
 Languages, Softwares and code 
Author Message
Rank 2
Rank 2

Joined: Mon Sep 01, 2014 3:43 pm
Posts: 5
Hello !

My question can seem a little stupid but what are the languages / softwares used to program and create the game? (i know Maya was used for the graphics)

(i searched in the forum, i don't think i'm reposting :? )


thanks :)


Wed Sep 03, 2014 9:10 am
Profile
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
XStoryPlayer is build in c++.

We use DirectX and OpenGl as rendering libs.
For images and video we use 3-party libs.

The models are made in Maya and then converted into custom format.

-------------------------------------------------------

We use a custom script language aimed at programming state machines.

It has similarities to c. But syntax is not the same.


SWITCH:

For example a switch statement is:

case (state)
{
[RUNNING] loc.run++;
[STOPPED] loc.run = 0;
[] loc.run = 0;
}


c: equivalent: switch (state) ...

Allowing for strings as well as other values. There is no need for break; To add more statements in the case clause use {}
The default clause is []

Because the case statement allows for strings its makes state machines is easier.


IF:

The if statement is also using the [] notation. To be similar to the case statement.

[state > 0] loc.a = 3;


c: equivalent: if (state > 0) loc.a = 3;

You can us or as follows:

[state > 0]
[state2 > 0]
[state3 > 0]
loc.a = 3;


c: equivalent: if (state > 0 || state2 > 0 || state3 > 0) loc.a = 3;

It is easier to read the bracket clauses, again aimed at making state machines easier.


VARS:

Var types are determined at runtime. So if you do loc.a = "hello"; 'a' becomes a string

If you do loc.a.b = "hello"; 'a' becomes a struct and 'b' a string.

You can also add vars. For example:

loc.a = "hello";
loc.b = 1;
loc.a += loc.b; // Now loc.a is "hello1"

Local values have prefix loc and are removed when out of scope of function.


FUNCTIONS:

You can declare a function in two ways.

<function1>

[par.a > 1] res = par.a;
else res = -1;

</function1>


The result of a function can be set by giving a value to res. The parameters of a function are accessible in par.

Call a function as follows:

loc.a = 3;
loc.res = function1(loc);


You can also declare a function inside a global var. Global vars have no prefix like loc,par,res.

So like this:

peter.data.get_age =
{
Trace("getting age");

res = 30;
}

Call this function as follows:

loc.res = <"peter.data.get_age">();


DYNAMIC CALLS:

A strong way to use these functions is dynamically:

loc.function = "peter.data.get_age"; // Assign function name to string

loc.res = <*loc.function>();

The star means to use the value of the var loc.function.

These types of calls are e.g. used to determine the AI response of the character to a natural language string.

// Hello, hi, hey...
hello.greet =
{
talk.s = "Hello";
}

// Have you seen my cat, where is my cat...
cat.see.you.if =
{
talk.s = "Hhhm I have not seen your cat.";
}

When the character gets an natural language event it looks up the appropriate response by calling:

<*event.talk.val>(); // event.talk.val can be for example hello.greet


OTHER:

- Rem comments are same as in c : /* */ and //

- You can include files similar to c: #include "filename"

- You can use defines that are replaced in the code before parsing.

- The var values are precompiled when possible. So if a value like "this is a long string" is used multiple times in the code only 1 string is stored.

- The script language is fast allowing for pretty complex code. A switch clause with 2000 string cases is just as fast as 20 causes, because it uses a lookup table for fast matching.

- You can only use integer, strings vars. Float values are converted to integers by multiplying them by 1000, allowing for 3 digit precision.

- Loops are possible but will always end. Syntax is:

[loc.a < 20]*3
{
loc. a += 1;
}

Runs 3 times max. To avoid locks in the scripts.


Hope this gives some idea. We will add simple scripts and examples in the future on this forum.


Wed Sep 03, 2014 10:03 am
Profile
Rank 2
Rank 2

Joined: Mon Sep 01, 2014 3:43 pm
Posts: 5
Ok, cool!!

thanks for such a complete explanation !!



:)


Fri Sep 05, 2014 10:36 am
Profile
Rank 16
Rank 16

Joined: Thu Jul 31, 2014 2:29 pm
Posts: 351
Out of curiosity, why use a custom script language instead of an established one such as lua?


Mon Sep 08, 2014 10:23 am
Profile
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
burning wrote:
Out of curiosity, why use a custom script language instead of an established one such as lua?


Main reason for this is that we wanted a script language that is very simple.
I hope we succeeded in that.

We also try to avoid 3-party software when we can.
Solving the bugs has been proven to be a source of problems in other software projects we have done.


Wed Sep 10, 2014 1:25 pm
Profile
Rank 7
Rank 7

Joined: Sat Sep 06, 2014 2:23 pm
Posts: 28
Personally this custom scripting language seems a lot harder to learn than for example Lua since its further away from c-style syntax, and Lua is not harder if you just want to make simple structures like loops and if cases and a lot more powerful if your an advanced user. Nevertheless im really looking forward to the ability to mod the game and play other mods, will really make this game stand out i think : D


Wed Sep 10, 2014 2:22 pm
Profile
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
@virror

Yes, learning a new script language does take some time.
The script language was developed for internal use only at first (when we first started XStoryPlayer).
We did not plan on adding modding to the amount that we are now doing.

The language is aimed to work well with the AI and language parser.
Basically as a bridge between the story and the engine.
In general the language is very VERY basic. All the complexity like physics and animations are done by the engine itself.

A function you call from the script language is for example SetFocusType(LOOK);
This means the character looks once in a while to the main character. The actual focusing is done by the engine itself.
Another command would be SetGesture(GREET); In this case the greet animation is started for the character.
The animation itself is described in the character setup, so only the command SetGesture is needed in the script.

So a small script could be:

loc.ts = GetTs();
[loc.ts > state.ts_wait_4sec]
{
SetFocusType(LOOK);
SetGesture(GREET);
state.curr_state = NEXT_STATE;
}


In this case after 4 second the character looks at the main and greets him, and then proceeds to the next state of the story.

Another function is SetPose. To let a character walk to a certain position do:

loc.pose = STAND;
loc.waypoint = "door";
SetPose(loc);


In this case the character walks to the door and stands there.
Again very basic. The actual walking, stopping and proceeding to the stand pose is done by the engine.

To run do:

loc.pose = STAND;
loc.waypoint = "door";
loc.speed = 2;
SetPose(loc);


New functions will be added in the future in cooperation with the community when needed.

We will see how things go when people are using it.
I think with simple straightforward examples things should not be very difficult.

N.b.
The script language is just a part of the modding you can do.
You can also add new animations/gestures/poses, change textures/models, change colors/sounds etc.
In fact the script language should be seen as the part in which all work comes together, not where its starts.


Thu Sep 11, 2014 7:58 am
Profile
Rank 7
Rank 7

Joined: Sat Sep 06, 2014 2:23 pm
Posts: 28
Sounds great, seems like we will be able to do quite a lot then : )


Thu Sep 11, 2014 8:20 am
Profile
Rank 12
Rank 12

Joined: Sun Oct 05, 2014 11:34 am
Posts: 82
@xpadmin,
Why did you choose to invent a scripting language? You are already spread thin just getting this game together with the resources you have.

I actually added Python to the T3D game engine about a year ago. I also learned about Lua a while back and it is dead simple to add to an existing codebase. I would say Python is as well if you use something like SWIG to do it. Another good option is the V8 engine (ECMA/Javascript).

I know that the T3D scripting language TorqueScript is pretty decent, but it is a pain to understand and maintain the interpreter. I spent a lot of time trying to rework that interpreter to work better. Any little tweak and all hell breaks loose. I would imagine your own interpreter is not much better. That is why I am asking why not use a proven scripting language and not have the hassle of inventing a new wheel.


Fri Oct 10, 2014 6:59 am
Profile
Site Admin
Site Admin

Joined: Thu Feb 07, 2013 11:16 am
Posts: 1865
BubbaGump wrote:
@xpadmin,
Why did you choose to invent a scripting language?


A few reasons:

1) We wanted the language to be very simple and restrictive. This in order to keep the focus on building the story and not on the script language itself.
We also wanted the Natural Language parsing to be an integral part of the language.

2) We have had issues with 3th party script languages in the past. Unexplained crashes that we were not able to solve.
We did not want to spend time trying out scripting language sdk's and then finding out they are unstable and/or would not suit our needs.

In most cases the 90-10 % rule applies here. A 3th party library gives you 90% very fast, but the last 10% can give you so much problems you then decide to use another sdk or to rebuild it yourself.
That would have resulted in a lot of time loss. So we only use 3th party libs that are simple, mainstream and easily replaced (like image lib, texture lib, sound lib, opengl/directx, math libs etc).


Sat Oct 11, 2014 11:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group.
Designed by X-Moon Productions.