Home   Help Search Login Register  

Author Topic: Parsing strings to objects/variables; Damn dialogs store text only!  (Read 1255 times)

0 Members and 1 Guest are viewing this topic.

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
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
The Captain

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
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

Dinger/Cfit

Offline uiox

  • Contributing Member
  • **
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?

Gameer_77

  • Guest

Offline uiox

  • Contributing Member
  • **
I know....

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
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.
Dinger/Cfit