Jump to content

support table similar in lua?


photo

Recommended Posts

Posted

any one here use lua? the table in lua is very power and flexible, especial useful when dealing with data files. hope can see it in unigine script.

Posted

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.

  • Like 2
Posted

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)

Posted

What kind of functionality you want?

May be there is an another solution of your task?

Posted

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.

Posted

yes, xml can describe any data you want, but you need to parse it, personal i don't like xml, it's big and awkward.

Posted

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
 )),
);

Posted

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?

Posted

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

×
×
  • Create New...