OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TheCaptain on 14 Oct 2002, 07:03:51

Title: Parsing strings to objects/variables; Damn dialogs store text only!
Post by: TheCaptain on 14 Oct 2002, 07:03:51
I'm writing a weapon purhcase menu. Problem: lbdata and lbsetdata only store text strings. My code basically checks what the user's selection is, and then grabs the price/name of the weapon/item from an array of the same name.

init.sqs defines all weapon arrays in format primaryweaponname = [displayname,price,weaponname,magazinename]
player selects M16 primary weapon
value of that option is read in and returned (m16)as "primaryweapon"
cashtemp then subtracts the value of primaryweapon select 1


This would all work great except for the fact that lbsetdata can only store a string in the dialog options, so when the primaryweapon is returned, it tries to use the string as an arry.

*shoots flashpoint*

Is there ANY command available to change the value of a variable from string to object? Or parse a string variable into a variable with type object/array?

The only other way i can think of is pretty nasty:

( if weapon selection is this string ) : (set primary weapon array to this array name)

And make lots of those..... ugh

Help?!

The Captain
Title: Re:Parsing strings to objects/variables; Damn dialogs store text only!
Post by: Dinger on 14 Oct 2002, 08:06:01
well, the answer is dirty.
If you're looking to convert a string to an object, here's one way that works:
"Myobject = " + MyString ForEach
Title: Re:Parsing strings to objects/variables; Damn dialogs store text only!
Post by: uiox on 14 Oct 2002, 12:21:54
The global variable you want to trap need to be initialize before.

The Dinger's tip (for each) can be use for many use.

A little tutorial will be nice, Dinger?
Title: Re:Parsing strings to objects/variables; Damn dialogs store text only!
Post by: Gameer_77 on 14 Oct 2002, 12:25:47
This Q has been answered over at the flashpoint1985 forums.

http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3daa8cc96336ffff;act=ST;f=7;t=21066 (http://www.flashpoint1985.com/cgi-bin/ikonboard301/ikonboard.cgi?s=3daa8cc96336ffff;act=ST;f=7;t=21066)

 8)PEACE
Title: Re:Parsing strings to objects/variables; Damn dialogs store text only!
Post by: uiox on 14 Oct 2002, 14:27:53
I know....
Title: Re:Parsing strings to objects/variables; Damn dialogs store text only!
Post by: Dinger on 14 Oct 2002, 17:12:19
You know I think there is a tutorial up over in the editors depot/tutorials.  My "Variables and Arrays in OFP" thing discusses transformations between types, including this.