[MSCI-library][17.02.08][V1.5]Incoming Question Handler (to include in other scripts)

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

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

User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

[MSCI-library][17.02.08][V1.5]Incoming Question Handler (to include in other scripts)

Post by SymTec ltd. »

To all scripters:

Sending an incoming question to the player is/was, in my opinion, a quite complicated thing to do, so people just did not do it. The following problems annoyed me most:
  • To send a question, you always had to have a special callback-script which disturbed you normal script naming schemes and added a lot to the work involved
  • Callback scripts ran global, so if you expected more than one question asked, you had to work with global variables and needed even more time to fiddle all out
  • All Questions were logged to the player logbook and created loads of spam
  • There was no "popup"-argument in "send incoming question"
Now, X3 2.5 gave us certain new features, which I almost immediately used to come up with a solution to this problem. I wrote a library that
  • can be called from any script on any object and returns the answer as soon as one is given
  • can run as many questions as wanted at one time, with one being picked at random everytime the player answers a question
  • do not get logged to the player logbook
  • do pop up once issued
This library is four files, to be placed in two folders, with one script to call from your script. This is about as easy as it gets. Release will be soon.

Download:
[ external image ]

Quick-"How to use this" (for scripters):
* Download package and read readme
* Place scriptfiles in "scripts", MD-files in "director"
* call script "lib.st.md.message.ask.xml" whenever you want to ask a question
* note that
** it might take hours for the player to answer a question if he decides not to
** the retvar is always a string or integer, never an object or any of the kind


Example: Simple script for offering the player some money and give it to him if he wants it:
Textfile:
[ external image ]
Scriptfile (recommended solution):
[ external image ]
Scriptfile (alternative solution):
[ external image ]

Changelog:
1.0 initial release
1.5 bugfix: errors could ocurr (leading to no questions being asked anymore) when an object that was just asking a question got destroyed. Added code to handle this situation in lib.st.md.message.ask.xml
Last edited by SymTec ltd. on Sun, 17. Feb 08, 18:26, edited 4 times in total.
Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam »

damn, you need a medal for this :), cant wait. this will probably spell the end of those enormously long callback scripts, which require so much time to write...

cant wait
eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan »

Agreed - sounds interesting STL. I'm curious about how you've done it - I don't know of any new functionality which would allow this, unless you're using the MD somehow?
User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

Post by SymTec ltd. »

eladan wrote:[...]unless you're using the MD somehow?
Erm... well... could be... yes. ;) :roll:

It is a rather simple script (40+10+5 lines) together with a rather simple MD-file (which is not used in the way it is meant to be - shame on me *g*). It would not be fair to release it yet, so I'm not - but it is ready and working.
eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan »

<Sigh> I wish the ES guys would get back on the job soon, so the rest of us mere mortals can find out a bit more about the MD... If you can do interesting things like this, I wanna play... :roll:
Osiris_sam
Posts: 422
Joined: Thu, 24. Aug 06, 13:45
x4

Post by Osiris_sam »

warning noob question: MD?
eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan »

Osiris_sam wrote:warning noob question: MD?
MD = Mission Director - the talk of the town since the recent patch! :D

:EDIT: I know - a bad habit. I need to be clearer when I write...
Last edited by eladan on Wed, 2. Jan 08, 15:35, edited 1 time in total.
User avatar
juanitierno
Posts: 451
Joined: Fri, 28. Dec 07, 17:06
xrvr

Post by juanitierno »

MD: Well, you know how mass driver bullets use a crystal to penetrate shields? my guess is he replaced the crystals with short paper messages that get splatted on your cockpit windshield.

j/k of course, i think theyr talking about the Mission Director that comes with patch 2.5 :)
User avatar
ninjitsumonk
Posts: 1874
Joined: Thu, 1. Mar 07, 09:21
x3

Post by ninjitsumonk »

Nice, yeah your not the only one who's going to be looking at all the other things the MD can do :).
Will check it out in a bit and see what I can do :).

Big question here, how did you do it?
Being the first one here(at least in this forum anyway - don't know about the other language forums) to experience the MD, care to share your experience?
Archeo Avis wrote:
if you take out phrasing and root notes and just look at the notes, they are the same
So what you're saying is, if you ignore everything that's different and focus only on the one thing that's the same, they're same.

Good God.
User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

Post by SymTec ltd. »

ninjitsumonk wrote:Big question here, how did you do it?
I have an object placed by MD and passed over to a script. MSCI handles everything up from then. Still, MD knows the object, and keeps waiting for it to change its name. The name-attribute is one of the few variables that can be accessed from both MD and MSCI. So, upon change of name, MD reads out the pilot name of that object as a string, makes it a question to send to the player, waits for an answer and returns this answer via scriptcall.

This all sounds pretty complicated, but the is no need whatsoever for anyone to know all this - the only thing you have to know is that you call one script with the message (or pageid/textid) as arguments, and then nothing will happen until the answer is returned and can be worked with.
ninjitsumonk wrote:Being the first one here(at least in this forum anyway - don't know about the other language forums) to experience the MD, care to share your experience?
In some ways, working with the MD was not so easy, mainly because the documentation was not completed at that point. But once you have a lookup table on variable use and scope, there is nothing un-understandable to it.

I do not, however, deem me the first one to have worked with the MD on these forums. This is just not true.

I uploaded the package just now and will soon update the OP.
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

not entirely in the scope of this, but ill ask here anyways

is it possible for the MD to on clicking an answer to ask the player for input of the "var/ship type" or similar..

or is it possible to ask for further player input after a script has started, for example, i start a script it asks for a player owned station...pops up a menu you click through the option and want to select a ware, rather than have a menu system with every single ware present in it could it call for another argument to be input "ware, var/ware, ware"
User avatar
ninjitsumonk
Posts: 1874
Joined: Thu, 1. Mar 07, 09:21
x3

Post by ninjitsumonk »

SymTec ltd. wrote: This all sounds pretty complicated, but the is no need whatsoever for anyone to know all this - the only thing you have to know is that you call one script with the message (or pageid/textid) as arguments, and then nothing will happen until the answer is returned and can be worked with.
Its fine, I know that nobody needs to know, I was just interested that's all. Haven't really had a major look at the MD so was just intrigued.
SymTec ltd. wrote: I do not, however, deem me the first one to have worked with the MD on these forums. This is just not true.

I uploaded the package just now and will soon update the OP.
Good to here, will check it out asap.

also, I realise the you aren't the first to work on it, however you are(unless I'm mistaken) the first to release some community MD work.

Thanks for sharing :)
Congratulations :)
Archeo Avis wrote:
if you take out phrasing and root notes and just look at the notes, they are the same
So what you're saying is, if you ignore everything that's different and focus only on the one thing that's the same, they're same.

Good God.
User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

Post by SymTec ltd. »

MJALowe wrote:not entirely in the scope of this, but ill ask here anyways

is it possible for the MD to on clicking an answer to ask the player for input of the "var/ship type" or similar..

or is it possible to ask for further player input after a script has started, for example, i start a script it asks for a player owned station...pops up a menu you click through the option and want to select a ware, rather than have a menu system with every single ware present in it could it call for another argument to be input "ware, var/ware, ware"
It is not possible to get a selection of ships on the sector map, or stations or wares without some serious coding. Of course, if you code a sector selection (by name?) and for this sector a ship selection (or just a selection from ships in alphabetical order), you can do this. But it is complicated.

What is possible, however, is to start a script (via ship/station command) and ask for a ship/station there, then find the array of wares (you want the player to select one of) from within that script and display the selection to him without a wait. Infact, you can always send him the selection from within the script at any point in time. I do, though, not recommend sending a popup-question to the player when he is not expecting it, as he might be in a fight or something.

@ninjitsumonk :)
MJALowe
Posts: 461
Joined: Fri, 5. Jan 07, 06:27
x3

Post by MJALowe »

*grin* im writing a manager script for IFTSOS, its evil...
User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

Post by SymTec ltd. »

Version 1.5 released
Fixed an error that could ocurr when the script got terminated in an unusual way (without being done). Compatibility is ensured; copying the changed file over the existing one will work perfectly fine.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Great work on the script/xls :P, it is very very useful (and much neater too)

I've noticed that there is a slight delay between selecting a button, and the next menu opening up and its probably because of the while,wait 150-250 statements, so I was thinking (I'm not much of an MD buff so I have no idea if this will work), couldn't you use "<run_script> Run script " from the MD, such that its an instant response sort of thing rather then continuous passive checks?
You could replace the while,wait checks, with beacon->call script dummywait script (A looping do nothing wait script), and then use the MD run_script to run on the beacon with a different task, and interrupt/terminate the dummywait script... hrmm... don't think you can terminate the task that easily... new idea, dummyway on some third object (a second beacon) and then explode it. It should work.... and should replace the need for the waiting
User avatar
SymTec ltd.
Posts: 5285
Joined: Mon, 11. Apr 05, 21:11
x3tc

Post by SymTec ltd. »

It is not really possible to have a script return a retvar in place of another script. Given that the delay is minimal and causes no big performance drops, I do not see a way to optimize the behavior on that point. From a programmer's perspective, it is of course not perfect, but the best I can do within the MSCI-limitations.
User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

I don't suppose you could also include an incoming message handler?
Essentially the exact same thing, sends a question (presumably with only an OK button, or just a message, I'm not to sure how if the MD allows it), however, does not have to wait for a return variable.

And just as a note on my last post, I was thinking that when the second beacon dies it should instantly return null, allowing the rest of the first script on the first beacon to run.
eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan »

STL, there appears to be a problem with the lib. Prior to the first call of the incoming question lib, it will always send a couple of incoming questions whenever you dock - one saying readtext 35-21, the other saying 'no pilot'. The problem seems to disappear after the first time the handler is used.

I've tried to take a look at the file to see if I could see the prob, but I really don't know the mission director at all. The best guess I can come up with is that the initial value of the pilot is incorrect, and triggers the action for STL_MessageHandler_Repeat. But it's all Greek to me, so who knows.
Deleted User

Post by Deleted User »

Theres a problems with the link. Get an error
Das ausgewählte Attachment existiert leider nicht mehr

The selected attachment sadly no longer exists
Does any one have this which could email it to me?

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