OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Mr.Peanut on 09 Sep 2008, 18:25:46

Title: Packing and unpacking publicVariable data
Post by: Mr.Peanut on 09 Sep 2008, 18:25:46
I am trying to make an enhanced publicvariable system in which each node has its own "channel", data may be sent from node to node, and a simple handshake verifies data delivery. As I plowed forward I suddenly realised "How the hell am I going to pack and unpack the data?"

Each node has a its own variable it monitors through a public event handler. Each "message" publicVariable'd through that variable has the form of an array:
Code: [Select]
[_tx, _datapack] where _tx is a header and
Code: [Select]
_datapack = []; {_datapack = _datapack + [[_x, call compile _x]]} forEach _data; where _data is an array of the variable names you want to PV.

How would I go about unpacking the data? Somehow I know:
Code: [Select]
{call compile (_x select 0) + " = " + str(_x select 1);} forEach _datapack;is garbage since the call compile _x used in data packing would, for objects, return local pointers not valid on the receiving machine. Help...  :blink:
Title: Re: Packing and unpacking publicVariable data
Post by: i0n0s on 09 Sep 2008, 19:34:20
The user has to give you the variable names and not the variable itself.
Title: Re: Packing and unpacking publicVariable data
Post by: Mr.Peanut on 09 Sep 2008, 20:31:52
He is, but I am wrapping them.

How about:
Code: [Select]
{_tmp = _x select 1; call compile (_x select 0) + " = _tmp;";} forEach _datapack;
Title: Re: Packing and unpacking publicVariable data
Post by: i0n0s on 09 Sep 2008, 21:35:51
That should work.