Home   Help Search Login Register  

Author Topic: Pass String to Data: Need Solution for CTRLText Command  (Read 2354 times)

0 Members and 1 Guest are viewing this topic.

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
I have a dialog that calls for PLAYER to enter data, a number between 0 and 360 representing heading.  I need to pass that input from the control, interpretated as a string, directly to a number that can be used by the setFormDir command.  Any ideas, short of one heck of a long script?


Thanks,
ADM
« Last Edit: 01 May 2005, 22:10:51 by Kundich »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #1 on: 02 May 2005, 16:05:45 »
Not very familiar with dialogs, but you should be able to get a string to a number with this:

Code: [Select]
_string = "120"
_number = call _string
« Last Edit: 02 May 2005, 16:06:01 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #2 on: 02 May 2005, 16:39:06 »
You had also better validate that the user has indeed input a number and not some text.  You might want to try using a slider to ensure youalways get a number

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #3 on: 02 May 2005, 20:28:23 »
HateR, let me understand: if you use the command CALL, it will convert text to the value of the text, i.e. "120" to 120?  That's pretty gosh-darned cool.  I can't believe I never knew that.

THobson, since my purpose is the entry of a directional heading, I would like to input the heading-wheel similar to the editor.  Any clue on how to make that control happen?

Thanks for the responses, guys.


Thanks,
ADM

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #4 on: 03 May 2005, 00:38:31 »
AFAIK, _number = call _string may not work. If it doesn't, try
call (format ["_number = %1", _string])
ensure that you define a value for _number before you use it.

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #5 on: 03 May 2005, 02:07:40 »
Correct me if I'm wrong on any of this.  I am still writing all the SQS files, so I haven't tested yet.  Essentially, I'm looking for PLAYER to control the deployment location and heading of a tripod M2 using onMapSingleClick and the Dialog that's giving me such fits.

_heading = 0
call FORMAT["_heading = %1",ctrlText 2]


This should return, for example:
_heading = 223
Am I understand you right?  I assumed it would return "_heading = 223", all quotes, a condition that renders my whole script useless.  I think I hear what you are saying.  I will try to test it out in the next couple of days.

Thanks for the tips.


Thanks
ADM

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #6 on: 03 May 2005, 05:17:02 »
AFAIK, _number = call _string may not work. If it doesn't, try
call (format ["_number = %1", _string])
ensure that you define a value for _number before you use it.
Worked just fine when I used it the last time...
Even a simple test using triggers works...

But that call format hasle works as well...

Quote
This should return, for example:
_heading = 223
As far I understand the dialog stuff, yes...
But that ain't much of a guarantee.. :P
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #7 on: 03 May 2005, 07:41:46 »
Sorry.  I don't know how to get a heading wheel.  But if you find it let us all know.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #8 on: 03 May 2005, 07:43:18 »
Oops, yes, I kinda posted without checking it. I covered myself with the word, 'may'.

Simple is best, though, so stick with _number = call _string then ;)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #9 on: 03 May 2005, 20:07:40 »
Hmmmm.......the heading wheel.

The resource file calls this azimut, and there is no resource definition of it, unlike all the other 3d dialogs.

It uses the texture file........azimut.paa, which is in the data.pbo.

This leads me to believe that it is hard coded into the game engine..........I can't even change the colour it is displayed with......and I have tried.


Planck
I know a little about a lot, and a lot about a little.

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #10 on: 03 May 2005, 22:24:17 »
I didn't think it was a resource we could tap, since it doesn't appear to have a define in an EXT file, but it was worth asking.  Thanks for the information.

Now I have to toy with the best way to allow individuals to input a desired heading.  It looks like we've got the user input control (type in the number, but hopefully not text) on a dialog or a slider-input (straight line with number ticks) on a dialog.  Does anyone have  a special preference?

The personal input does require some kind of control to ensure that players don't type in a combination of letters and numbers.  Any ideas on how to do that?


Thanks,
ADM


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #11 on: 03 May 2005, 22:43:20 »
If the azimut resource is used in the resource.bin file for use in the game editor, then I presume it should also be available for user dialogs as well.

I will try to see what I can find out, it might just be a case of extracting the resulting number from......wherever.


Planck
I know a little about a lot, and a lot about a little.

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #12 on: 04 May 2005, 01:15:05 »
Yes, the deep, dark depths of...wherever.  I have heard of such a place.  I wish I could help, but I really don't know the first thing about all the stuff.  I just figured it was a lost cause.


Thanks,
ADM

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #13 on: 04 May 2005, 19:53:49 »
Well, I tried.

I can get the texture file azimut.paa to display correctly in a dialog and even the edit box for the direction.......just like the ones in the mission editor.

And it all came back to me where I got stuck last time I was playing with this.

The sticking point is the small arrow pointer resource, it is nowhere to be found, I think it is part of the game .exe file because it is not defined anywhere and it isn't a texture that I have found yet.

The best you can do I think is to make a small dialog with an edit box for input of the direction.

And then check for valid input in a script.


Planck
I know a little about a lot, and a lot about a little.

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #14 on: 05 May 2005, 00:09:23 »
Planck,

I appreciate your efforts.  

Can I ask a really stupid question?  In an SQS, how can a check for a valid input?  I know it sounds pretty lame.  I don't need much information, just an idea of how to structure the SQS.  I really like the specific number input rather than the slider, so I imagine no one has a real problem with it.


Thanks,
ADM