Doolittle/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:


== Important Links ==
== Important Links ==
[http://community.bistudio.com/wiki/ArmA:_Version_History Version History]
[[ArmA:_Version_History]]


[http://community.bistudio.com/wiki/Category:ArmA_Classes ArmA Classes]
[[:Category:ArmA:_Editing]]


[http://community.bistudio.com/wiki/ArmA:_Moves ArmA: Moves]
[[ArmA:_Moves]]


== My Fav Function So Far ==
== My Fav Function So Far ==

Revision as of 20:45, 28 July 2007

Ah, scripting. Here's some fun stuff: myfunc = {objnull}; _unit = ["foo"] call myfunk; if (isnull _unit) then {hint "wow!"}; You won't see "wow". The error is it should be spelled myfunc... but it's hard to catch because, since myfunk is not defined, _unit is not defined, so isnull on a not defined var doesn't even work. So it's hard to track what went wrong here.

More interesting stuff about private. I never got private. Why is it needed? This was interesting: myfunc = { _temp = [1,2,3]; myglobal = _temp; }; call myfunc; player sidechat str myglobal; myglobal comes out empty. But if you put private ["_temp"] then it is filled with values. Like the engine knows it's a temp var and so copies it over. Otherwise it doesn't think it's temp (without private) so it doesn't bother to copy, but then the value gets dropped from memory anyways.

I've noticed that when you are working with arrays, if the array isn't properly initialized, either with private or a simple _temp []; then you get some undefined type errors and unexpected results. As soon as you initialize the array it seems ok. I've just noticed this over the past few days myself. hoz

Important Links

ArmA:_Version_History

Category:ArmA:_Editing

ArmA:_Moves

My Fav Function So Far

I figured this out the other day. Maybe it's worth a share. If you have the server sending out publicVars from several scripts... and you want to make sure the users receive all of them (some might get squashed).. here's an easy way to "cache" those publicVariables so that they get sent out at least 1 sec. from each other. publicvarcode = { if (isnil format ["%1time", _this select 0]) then {call compile format ["%1time = time", _this select 0]}; waituntil {call compile format ["%1time < time", _this select 0]}; call compile format ["%1 = _this select 1; publicvariable ""%1""; %1time = time + 1", _this select 0]; }; // example ["foobar", "The base is under attack!"] spawn publicvarcode; ["foobar", "Oh no!"] spawn publicvarcode; ["foobar", "Run!"] spawn publicvarcode; ["anObj", player] spawn publicvarcode; Note waituntil with a call compile inside may be expensive. It took a while to figure out how to get the second argument to send no matter what var type it was.