Jump to content

support table similar in lua?


photo

Recommended Posts

Just use Lua. It's not a problem to export Unigine functionality via one of existing(or write your own) Lua-C-bind libraries.

We checked it - works well.

 

yes, that should work, but not so convenience especial considering interaction with user interface(as ungine has native script support to gui)

Link to comment

What kind of functionality you want?

May be there is an another solution of your task?

 

i want use script to describe data directly, for example all item of a game can be described as follow in lua

{

[0] = {

"name" = "test1",

"damage" = 30,

"on_attak" = function(xxx) end

...

},

 

[1] = {

"name" = "test2",

"hp" = 30,

"onused" = function(xxx) end

...

},

}

 

i think this way is very flexible.

Link to comment

There are two generic array wrappers Unigine::Vector and Unigine::Map. It's possible to use arrays inside the arrays:

int data[] = (
 new Unigine::Map((
   "name" : "name 1",
   "health" : 20
 )),
 new Unigine::Map((
   "name" : "name 2",
   "health" : 40
 )),
);

Link to comment

There are two generic array wrappers Unigine::Vector and Unigine::Map. It's possible to use arrays inside the arrays:

int data[] = (
 new Unigine::Map((
   "name" : "name 1",
   "health" : 20
 )),
 new Unigine::Map((
   "name" : "name 2",
   "health" : 40
 )),
);

 

this doesn't work

Unigine::Map m1 = new Unigine::Map(("name" : "name 1"));

printf("%s", typeinfo(m1.find("name 1")));

will output int:-1

 

after view the source of <core/scripts/array.h>

add construct function to Map

Map(int d[]) {

data = d;

}

will give correct result.

 

so this is a bug?

Link to comment

I didn't check this sample...

 

This is an updated array.h file. Which will be available in next SDK update.

 

I have added constructors to Unigine::Map.

 

There is no single argument constructor for Unigine::Vector which was specified the vector size.

array.h

Link to comment
×
×
  • Create New...