Home   Help Search Login Register  

Author Topic: Pass String to Data: Need Solution for CTRLText Command  (Read 2338 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

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 #15 on: 05 May 2005, 00:23:31 »
Well, I'm no expert scripter but the link below is a little thing I was playing with earlier today.

Try it out and see what you think.......it isn't perfect but it traps most invalid input.


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 #16 on: 05 May 2005, 02:13:47 »
The coding looks so simple.  Why couldn't I come up with something like that?  Ought to work nicely.  I will check it out and let you know.  Only one thing, though.  You've got:

_dir2 foreach


I don' t actually know why that's in there.  I mean, I understand the forEach command, but I don't get how it's being used there.  Is it a reference to PLAYER id?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #17 on: 05 May 2005, 19:54:33 »
I have only looked at the script, not run the mission.  What happens if the player enters: I am a burk  or sadferfgud  or any other non-numeric character?

I suppose you could crudely simulate an azimuth wheel by placing a lot of small buttons in a circle

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 #18 on: 05 May 2005, 20:03:27 »
It is only a very simple check for valid input.

It will detect if the input is less than 0 or greater than 360.

If you enter 'I am a burk', then it will pop the hint 'Invalid Input'.

If you enter '2I am a burk' it will still pop the hint, but, it will also produce a script error message.

In short, if the first element is a number followed by an alphabetic then a script error will appear as well as the hint.

If the first element is an alphabetic then it will pop the hint and there will be no script error message.


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

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #19 on: 05 May 2005, 21:47:23 »
I hate having to give a user a text field to input - you just have no idea what they will think of putting in it.

35 degrees please.

Has anyone got time to create an azimuth wheel? - I think one with 720 buttons might be quite usable
« Last Edit: 05 May 2005, 22:16:19 by THobson »

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 #20 on: 05 May 2005, 21:57:52 »
Hmmmmmm..............I wonder if using a horizontal or vertical slider would work?

Then again the result would probably still be a string.


Planck
« Last Edit: 05 May 2005, 21:58:17 by Planck »
I know a little about a lot, and a lot about a little.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #21 on: 05 May 2005, 22:17:08 »
I have not use sliders yet - if they return a string at least it will be a predictable srting.

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 #22 on: 05 May 2005, 22:21:20 »
I think I might have a play with this tomorrow   ;D ;D


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

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #23 on: 05 May 2005, 22:46:45 »
I will be in the office :'( :'(
« Last Edit: 05 May 2005, 22:46:57 by THobson »

Offline Kundich

  • Members
  • *
  • "Habit is the daily battleground of character."
Re:Pass String to Data: Need Solution for CTRLText Command
« Reply #24 on: 06 May 2005, 01:21:00 »
Even if the sliders return a string, we should be able to convert it to data as with the CALL command, right?  Actually, I suspect the slider will only return a string if you set the value of the slider's data to be a string, but then again I'm shooting from the hip on this one.

And Thobson, I will be in the office also.  TGIF, right?

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 #25 on: 06 May 2005, 19:26:21 »
Ok, I made another little dialog which uses the horizontal slider.

Try it out and see if it is what you need.

The dialog is not started from the players init field with this one, you can start the dialog from the action menu.......repeatedly.

EDIT:  I'm getting forgetful in my young age.

Clicking on the arrows on either end of the slider will increase/decrease the bearing by 1, clicking on the scale portion of the slider will increase/decrease the bearing by 10.

Sliding the slider itself will increase the bearing more rapidly, but also introduces a decimal portion to the bearing....under 100 you get a number to 4 decimal places......over 100 it is reduced to 3 decimal places.



Planck
« Last Edit: 06 May 2005, 21:07:49 by 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 #26 on: 09 May 2005, 16:07:57 »
Planck, I will check this sucker out and let you know how it works.


Thanks,
ADM