Doolittle/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search

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.