OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Kundich on 01 May 2005, 21:17:00
-
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
-
Not very familiar with dialogs, but you should be able to get a string to a number with this:
_string = "120"
_number = call _string
-
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
-
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
-
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.
-
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
-
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...
This should return, for example:
_heading = 223
As far I understand the dialog stuff, yes...
But that ain't much of a guarantee.. :P
-
Sorry. I don't know how to get a heading wheel. But if you find it let us all know.
-
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 ;)
-
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 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
-
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
-
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
-
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
-
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
-
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
-
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?
-
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
-
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 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
-
Hmmmmmm..............I wonder if using a horizontal or vertical slider would work?
Then again the result would probably still be a string.
Planck
-
I have not use sliders yet - if they return a string at least it will be a predictable srting.
-
I think I might have a play with this tomorrow ;D ;D
Planck
-
I will be in the office :'( :'(
-
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?
-
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
-
Planck, I will check this sucker out and let you know how it works.
Thanks,
ADM