plugin: data type convertion and push_back problem

Typically: "How do I... ", "How can I... " questions
Post Reply
jacobi
Posts: 11
Joined: 13 Aug 2015, 22:27

plugin: data type convertion and push_back problem

Post by jacobi »

Hi, coppelia,

I am developing a plugin, which has two functions:
1. simExGetDataHandleByName
return a long type back to lua

2. simExReadDataByHandle
use the above returned handle to retrieve data.

My problem is that, since the handle is 8 bytes long (e.g. 5033165514562), if in the plugin I use
D.pushOutData(CLuaFunctionDataItem(handle));

And then call in an add-on function:
handle = simExGetDataHandleByName ("varName1")
simAddStatusbarMessage(tostring(handle))

it will give a nil, rather than the 8 bytes long value.

Should I try to seperate the 8 bytes into two integers (int type) or a charbuffer and then use them in Lua script? Is there any better approach? Thank you!!

coppelia
Site Admin
Posts: 8125
Joined: 14 Dec 2012, 00:25

Re: plugin: data type convertion and push_back problem

Post by coppelia »

Hello,

have a look how things were done in the plugin programming/v_repExtRRS1. Take for instance following 2 functions that correspond to your two functions:
  • simExtRRS1_INITIALIZE
  • simExtRRS1_TERMINATE
Both callbacks use a sim_lua_arg_charbuff of size 8 for the handle argument.

Cheers

Post Reply