Jump to content
Sign in to follow this  

Converting dialog string to object

Recommended Posts

I'm working on a GUI control that will allow map click teleport of any connected players. I have script that creates a listbox containing the unit names of each player:

_listboxB = 3100;
_display = _this select 0;
_index = lbAdd [_listboxB, str(_x)]; 
} forEach allUnits;  // <---- this will be changed to only be for playable units once it's working.

(_display displayCtrl _listboxB) ctrlAddEventHandler ["LBDblClick","_this execVM 's\GUI\gui_teleport.sqf'"];

The ctrlAddEventHandler then fires a script when the desired unit is doubleclicked:

//Get the passed ctrl 
_ctrl = _this select 0; 

//Get passed selected index 
_index = _this select 1; 

picked = (_ctrl lbText _index); //This creates the text that was displayed in the listbox index that was selected

onMapSingleClick "picked setPos _pos; true; onMapSingleClick '';";

Here's the problem... the variable, picked, is injected into the teleport code as a string, wrapped in quotes, and I get a script error that it's expecting an object, but got a string. I've been going crazy trying to find a way to remove the quotes so the script will take it, but I've gotten nowhere, and I'm out of ideas.

Anyone have any ideas?

Share this post

Link to post
Share on other sites

Try (untested):

picked = call(compile(_ctrl lbText _index));

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this