Hi guys, I have been playing with Small and I like it a lot, but I have some questions that maybe someone with more experience would answer.
For the game I am working on, I have licensed the Cipher engine (www.cipherengine.com). I replaced DirectInput and window management by SDL, DirectSound by OpenAL, and the network functions by SDL_net, to make it work on Linux and MacOSX systems.
Now, I want to add a good scripting engine to it, so the game logic is coded in 100% portable scripts instead of the dlls you normally use in Cipher (it works like in the Quake engine: one dll for the server, another for the client, and one more for the user interface), and to implement a language that allows for faster development than C.
I found Small perfect for the purpose. Considering that it is based on C, but with simplified syntax, it would fit perfectly the structure of Cipher, which is also coded in C. I would only have to export all the functions of the engine to the virtual machine, and that would be all.
But I have encountered a problem. Small does not support any type of structures, but this is not a problem because the way it works with enum lists is very powerful. You would declare an enumerated list like:
enum myList
{
myField1,
myField2,
myField3
}
And then create an arraw which will hold this data:
new myVar[myList]
myVar[myField1] = 45
myVar[myField3] = myVar[myField2]
So you have a very limited support for structures using arrays and enum lists.
Well the problem is the following. Imagine that I have this two enum lists:
enum viewinfo_t
{
x, y, w, h, // Viewport position and size
fov_x, fov_y, // FOV value fo the camera
posx, posy, posz, // Camera position
pitch, yaw, roll, // Camera angle
fogstart, fogend, // Fog begin and end positions
fogr, fogg, fogb // Fog color (RGBA format)
}
enum iteminfo_t
{
type, // Type of item
model, // Handle to the model
posx, posy, posz, // Position of the node
pitch, yaw, roll // Angle of the node
}
Then, if I create an array to hold information for an item, and try to modify its 'roll' field, like this:
new item[iteminfo_t]
item[roll] = 20
I get the following error:
Quote:array index out of bounds (variable "item")
This is because it takes the value of 'roll' from 'viewinfo_t' (which is 11) instead from 'iteminfo_t' (which is '7'). As 'iteminfo_t' is an array which 8 indices, it gives that return.
I thought that using 'item[iteminfo_t:roll] = 20' should fix it, but it gives the same error... does anyone know how to do this?