Home   Help Search Login Register  

Author Topic: publicVariable and object namespaces [solved]  (Read 2201 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
publicVariable and object namespaces [solved]
« on: 15 Jul 2010, 19:05:14 »
Are the contents of an object's namespace sent when the object is broadcast with publicVariable? Or does the namespace remain local to the object?
« Last Edit: 16 Jul 2010, 21:03:21 by Mr.Peanut »
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: publicVariable and object namespaces
« Reply #1 on: 15 Jul 2010, 21:20:07 »
It dpends
if you used object setVariable ["xxx", 24, true];
then yes, last false/true means dont broadcast / broadcast.

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: publicVariable and object namespaces
« Reply #2 on: 16 Jul 2010, 08:13:36 »
No it does not transfer the complete namespace - from what I know.
As mando says, you need to setVar public each variable on your own.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: publicVariable and object namespaces
« Reply #3 on: 16 Jul 2010, 13:39:16 »
I see. I did not know that option for broadcasting existed. I presume the default would be "False"?

Next question. If broadcast is set to "True" will a publicvariable event handler on the object pick up the change? Suspect yes...
urp!

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: publicVariable and object namespaces
« Reply #4 on: 16 Jul 2010, 14:01:04 »
what do you mean by that?

Quote
publicvariable event handler on the object

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: publicVariable and object namespaces
« Reply #5 on: 16 Jul 2010, 14:22:31 »
That,
Code: [Select]
myUnit setVariable ["paranoia",15,true]will cause
Code: [Select]
"myUnit" addPublicVariableEventHandler {hint str(_this select 1)};to fire (on other clients).

BTW. Is the _this select 1 in the addPublicVariableEventHandler passed by reference or value?
urp!

Offline Loyalguard

  • Former Staff
  • ****
Re: publicVariable and object namespaces
« Reply #6 on: 16 Jul 2010, 18:04:06 »
As far as I can tell, using setVariable with true for public broadcast will NOT fire a PVEH.  You would probably have to run a separate monitoring loop script to check for changes.  Example (untested):

Code: [Select]
while {true} do
{
     _cur = myUnit getVariable "paranoia";
     waitUntil {_cur != (myUnit getVariable "paranoia")};
     hint str(myUnit getVariable "paranoia");
     sleep .01;
};

Not sure if still relevant, but with addPublicVariableEventHandler, _this select 0 always refer to the name of the variable, _this select 1 is always the value of the variable.
« Last Edit: 16 Jul 2010, 23:01:01 by Loyalguard »

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: publicVariable and object namespaces
« Reply #7 on: 16 Jul 2010, 18:42:46 »
By value.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: publicVariable and object namespaces
« Reply #8 on: 16 Jul 2010, 21:03:03 »
k. thanks. solved.
urp!