[lib Script ideas] Player Numeric Entry V3 - BOF - updated 2008-01-05

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

[lib Script ideas] Player Numeric Entry V3 - BOF - updated 2008-01-05

Post by B-O'F » Tue, 15. May 07, 00:05

Numeric Data Entry pack Version 3 - 2008-01-05

Updated with a new method - incoming question using 'Incoming Question Handler' by SymTecs ltd (included in the pack by the kind permission of Symtecs ltd).
- Calculator style keyboard which 'pops-up' - so no searching for the message.
- Messages are not written to the logbook - saves all that bloat
- Number entered is formatted, default is to use comma separators, but it is easily changed in the t-file.

Contains everything that was in version 2 as well....

Version 3 available Courtesy of Xai Corporation

Numeric Data Entry pack Version 2 - 2007-06-12

Updated with a lot more information.

This pack is intended for scripters old and new - a lot of documentation for the learner plus working scripts and ideas.

All scripts are meant to be used, modified or just looked at, and are freely available for your own use. If you do use any scripts, then rename them to match your script pack - and of course, change them to do exactly what you want.

The main problem with using scripts is that the user is expected to enter all required information before a script is started. This can limit the use of a script.

If a user is allowed to enter data while a script is running, then the script becomes more flexible. This is not easy with standard scripts, hence this collection of information.

Scripts, hints and tips for the following methods of getting input from the user once a script is running:-

- Incoming question in the form of a numeric keypad - slight update on the original.

- Using the numeric keypad (hotkey) from a script - plus other uses.

- Using a combination of numeric keypad and incoming question.

- "Chaining" scripts to change the function of the command slot - not just for numeric entry, but any entry.

Version 2 available Courtesy of Xai Corporation

Use, learn, and enjoy.

Boron - Ol Fh'art

Update
A tip from UniTrader {KBG}
Something that I did not know:-
B-O'F wrote:
----------------------------------------------------------------------------------
Standard warnings about incoming messages - everything is written to the logbook, and you get that annoying 'incoming message'.
---------------------------------------------------------------------------------

i dont know if you have already solved this, but if not here a small tip from me:

Code: Select all

send incoming question $String to player: callback=<Script Name> 
= speak text: page= 0 id= 0 priority= 100 
with the second line the 'incoming message' will be disabled
----------------
I said, use, learn and enjoy - well I have just learned something else......

---Original text ---------------------------------------------------
Many times I have seen requests for a way of getting numeric entry from the player while a script is running. There is no way that this can be done --- UNTIL NOW.

This is a set of 3 scripts and a t-file, that uses the incoming question command.


Easy to use - just call 'lib.bof.enter.number', it will return the entered number, or null if cancelled.

The incoming question lays out the keys in a calculator-type format, with the currently entered number at the top:-

Code: Select all

        476   

[1]	[2]	[3]
[4]	[5]	[6]
[7]	[8]	[9]
      [0]	
[CE]		[Cancel]
	[Enter]
CE is Clear Entry - resets the entered number to zero
Enter when the completed number has been entered.
Cancel aborts the entry.

The screen is instantly refreshed, updating the entered number - no need to get the next message.

The maximum entry is 2,147,483,647 - after that it goes funny... but that should be large enough for most entries.

----------------------------------------------------------------------------------
Standard warnings about incoming messages - everything is written to the logbook, and you get that annoying 'incoming message'.
----------------------------------------------------------------------------------

Other than that, it works very well (what else do you expect from me!).

Scripts:

If you change anything in these scripts, then please rename them.

Remember to change the names called by lib.bof.numeric.entry and lib.bof.num.entry.callback - almost the last line in each. They both call each other - this way the 'keyboard' stays on screen.


lib.bof.enter.number
- handler, starts numeric entry, passes back the answer. You could copy this code into your own script to handle Cancel differently.


lib.bof.numeric.entry
- builds the incoming message, and handles the returned answer. CHANGE the t-file references to your own.


lib.bof.num.entry.callback
- returns the players response to the incoming question - it's only a one liner.


Only one script refers to the t-file - lib.bof.numeric.entry

t-file
- just the data required for numeric entry - copy it to your own t-file.
Currently it is 448893 so you can use this to test it out

Change the $page.id and load text: id in 'lib.bof.numeric.entry' to match your t-file number.

If you change the <t id="xx"> then also change the textid= for msg01, msg02, and msg03 in 'lib.bof.numeric.entry'.

If you change the data in the t-file, especially the \n's, then the formatting will go to pot.. you will then have to try to sort it out....


Available Here as a .zip file, courtesy Xai-Corporation.

Use and enjoy,

Boron - Ol Fh'art
Last edited by B-O'F on Sat, 5. Jan 08, 19:27, edited 4 times in total.
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

eladan
Posts: 5338
Joined: Sat, 7. Jan 06, 17:01
x4

Post by eladan » Tue, 15. May 07, 01:33

Oh, now this is neat.

You've got a (very good!) habit of coming up with scripts that fill much needed holes, B-O'F. Keep it up!

Squelch
Posts: 252
Joined: Sat, 15. May 04, 11:03
x2

Post by Squelch » Tue, 15. May 07, 01:57

Hi

All I can say is - Wow!

Are you a member of the thought police? I was just looking for exactly this. Wierd.

One thing. lib.bof.numeric.entry.xml

Code: Select all

096   send incoming question $message to player: callback="lib.bof.num.entry.calback"
I haven't seen callback documented anywhere or used like this, so would

Code: Select all

096   send incoming question $message to player: callback="lib.bof.num.entry.calback" temporary=TRUE
avoid the log entries?

I haven't used this yet so I haven't tested that out.

Thank you, thank you. You have saved me some work :)

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Tue, 15. May 07, 11:03

Hi Squelch and eladan,

Glad you ike it.

@ Squelch

There is no incoming question command with a 'temporary = ' clause, that is only available for incoming messages - unfortunately.

You will have to think a bit louder on what you need next...


To all,

As ever with my sripts, use what you want - save yourselves some work.

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Brand-X
Posts: 232
Joined: Thu, 15. Sep 05, 23:48
x3

Post by Brand-X » Wed, 16. May 07, 08:59

This is excellent, B-O'F. I was dreading having to try to figure out a way to get numeric values into a script, as I have a need for this very thing. This will work just fine. You have saved me a lot of trouble. Thanks.

:)

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Wed, 16. May 07, 10:13

Hi Brand-X,

The purpose of the script is to help you, and others, save time fiddling around with minor details so that you can concentrate on the major parts of your scripts... or something like that.

But wow - three satisfied customers..... nearly a record for me....


Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

User avatar
X-Freak Cartman
Posts: 3586
Joined: Mon, 2. Oct 06, 15:08
x3

Post by X-Freak Cartman » Wed, 16. May 07, 18:12

Hmm... imho, it's a bit unhandy. My version would be to send a question asking the player to use new hotkeys for the numeric input. This way, you can use the numpad (I'd use Shift+[Numpad] for it so it's compatible to most of the scripts... FCC and my fleet management system would be the only scripts causing a problem) . The number is saved in a global variable...

To see what you entered, you could use subtitles.

If you close the question using the "OK"-button, the answer script is used which stops the numeric input ans makes the hotkeys unusable until the next script asks for an input.

You'd need a single globvar: The one containing the number.
If there's a number, the input is activated. Using the hotkeys changes the number. the globvar is set to zero and saved in another globvar used by the scripter's script.

Scripting it doesn't take that much time... tell me, if you want me to do so ^^

What's uncomfortable with your solution is that you either have to use the mouse or the arrow keys... well, the up and down arrow keys, left and right doesn't work afaik.

I just can't handle it this way...

hf
- EL
Image
MSCI Referenz
Inaktiv

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Wed, 16. May 07, 18:37

Hi X-Freak Cartman,

Never thought of that, I was just using the incoming message (which I know is rather clunky)... I was using it with the mouse, as it was quicker.

I will have a look at your suggestion, sounds interesting.... something else to learn...


Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

User avatar
X-Freak Cartman
Posts: 3586
Joined: Mon, 2. Oct 06, 15:08
x3

Post by X-Freak Cartman » Wed, 16. May 07, 19:10

^^

Fortunately, there's no copyright.
Have fun scripting it ;)

- EL
Image
MSCI Referenz
Inaktiv

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Wed, 16. May 07, 20:50

Have fun scripting it
That sounds ominous...

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Fri, 18. May 07, 11:19

Hi,

I have been looking into the suggestion by X-Freak Cartman, and I have come across a problem, which I cannot fix.

Problem: Hotkeys do not work when docked.
I have checked with all the scripts that I have installed - none of the hotkeys will work when docked. The key binding screen of all the installed scripts shows "Availability: Always" - but they still will not work when docked.

This will severely curtail the use of the script.

Does anyone have an answer to this?

Please ?

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Squelch
Posts: 252
Joined: Sat, 15. May 04, 11:03
x2

Post by Squelch » Fri, 18. May 07, 11:31

I think the always bit is broken. None of the shortcuts to station menus work either, even though they are shown in the setup controls screen. eg b for BBS. (note this is defualt setting)

The only buttons that appear to work are arrow keys (maybe shft+arrow)

Function keys appear to work too, and some others.

User avatar
X-Freak Cartman
Posts: 3586
Joined: Mon, 2. Oct 06, 15:08
x3

Post by X-Freak Cartman » Fri, 18. May 07, 11:44

I'd like you to try it with Shift+[Something]. When you're in a menu, like the stations menu, the normal keys are unavailable.

That's a problem I had with my Optimized Targeting scripts: I always had to leave the X3IGSE to select another ship... the solution is to use Shift+[+] and Shift+[-].

If it doesn't work, there's no other way to use the hotkeys...

What about a combination of both versions? Using a refresh-button, you can see the number entered with the hotkeys and while being docked at a station, you can use your version of numeric input ;)
Image
MSCI Referenz
Inaktiv

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Fri, 18. May 07, 13:48

Hi X-Freak Cartman,

I think That I have found out why you said:-
Have fun scripting it
I was testing with Shift + NumPad 1 - it didn't work.

Using function keys is possible - but conflicts with many settings.. the most logical ones to use are already used.

I was looking to offer a choice of entry methods - the player to choose the prefered entry method.

But if one method only works while 'flying' this has to be explained to the player.. Seeing a different screen coming up for the same script - which is not the prefered one - is confusing and counter-productive.

It looks like the current version is the only one that works under all circumstances. Therefore, regretfully, I believe that this should be the one generally available.

I will add the information I have learned, document the steps, and supply sample code, for both methods in a future version of the 'Sorts and Strings' - and oher things, then scripters can use the existing method or write their own - based on working code. That being the reason for issuing the 'S & S' package.

Of course, if someone comes up with a way of making it work... things would change.

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Tue, 12. Jun 07, 13:59

Updated to Version 2.0, as per the first post.

Now has Keyboard (hotkey) input and script "chaining".

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Post Reply

Return to “X³: Reunion - Scripts and Modding”