OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: OzDeaDMeaT on 07 Dec 2010, 20:33:26

Title: Dynamic Creation of Names
Post by: OzDeaDMeaT on 07 Dec 2010, 20:33:26
Hi again,

I am wondering if its possible to create dynamic variable names.

E.G. Position_1 is the name of a game logic in game. I want to be able to dynamically create a marker called Position_1_Marker.

Is there a way to get the entity name and add another string to it to make another variable name and then use that name to create the marker?

I would like to do similar things with ammo boxes, flag poles.

The goal is to have a script create an entire capture and hold position including markers, ammo boxes, flags, triggers, everything.
Title: Re: Dynamic Creation of Names
Post by: Spyder001 on 03 Jan 2011, 10:21:02
Here is a short answer because I'm not sure how you are executing all this and what the entire scope of what you are trying to do is.

Code: [Select]
// This goes in the gamelogic you have
// _null = [this, 'Position_1'] execVM "logic_marker.sqf";

// this select 0 is this, this select 1 is the object name you define
_object = this select 0;
_objectName = this select 1;

// The name format you want to use, based on what the object name is
_markerName = format ["%1_Marker", _objectName];

// Creates the marker at the position of the gamelogic with the dynamic name
_marker = createMarkerLocal [_markerName, getPos _object];
// rest of marker stuff ...