add CBA_fnc_createNamespace and CBA_fnc_deleteNamespace #260

Merged
merged 2 commits into from Feb 13, 2016

Projects

None yet

3 participants

@commy2
Contributor
commy2 commented Feb 11, 2016

This is a faster alternative to creating pseudo-namespaces compared to createVehicleLocal with Logic or similar. It also never runs into any limitations regarding group count and is strictly local.
It is based on creating a location outside of the map which is used as container for variables.

Perf test:
call CBA_fnc_createNamespace;
0.0207031 ms
(10000/10000)

"Logic" createVehicleLocal [-1000,-1000,0];
0.138744 ms
(6649/10000)

Usage:

test_namespace = call CBA_fnc_createNamespace;
test_namespace setVariable ["test_value", 123];
test_namespace getVariable "test_value"
-> 123
allVariables test_namespace
["test_value"]
test_namespace call CBA_fnc_deleteNamespace;

Only downside is, that the getVariable ARRAY syntax does not work it.

@commy2 commy2 added the enhancement label Feb 11, 2016
@commy2 commy2 self-assigned this Feb 11, 2016
@Killswitch00 Killswitch00 commented on an outdated diff Feb 13, 2016
addons/common/fnc_createNamespace.sqf
+Parameters:
+ None
+
+Returns:
+ _namespace - a namespace <LOCATION>
+
+Examples:
+ (begin example)
+ _namespace = call CBA_fnc_createNamespace;
+ (end)
+
+Author:
+ commy2
+---------------------------------------------------------------------------- */
+#include "script_component.hpp"
+
@Killswitch00
Killswitch00 Feb 13, 2016 Contributor

SCRIPT(createNamespace);

@Killswitch00 Killswitch00 commented on an outdated diff Feb 13, 2016
addons/common/fnc_deleteNamespace.sqf
+Parameters:
+ _namespace - a namespace <LOCATION>
+
+Returns:
+ None
+
+Examples:
+ (begin example)
+ _namespace call CBA_fnc_deleteNamespace;
+ (end)
+
+Author:
+ commy2
+---------------------------------------------------------------------------- */
+#include "script_component.hpp"
+
@Killswitch00
Killswitch00 Feb 13, 2016 Contributor

SCRIPT(deleteNamespace);

@Killswitch00 Killswitch00 merged commit f5ac24b into master Feb 13, 2016
@esteldunedain
Contributor

Perfect for ACE. Thanks

@Glowbal Glowbal deleted the createNamespace branch Apr 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment