Author Topic: Prompt Box: An easy way to get a user response  (Read 14983 times)

0 Members and 1 Guest are viewing this topic.

Offline Axem

  • 211
Prompt Box: An easy way to get a user response
How many times has this happened to you?

"During a mission, I just asked the player a question. How do I get a response out of him?"

Normally the answer to that question has been "Well you just throw up a training message and ask him to press 1,2,3 or 4!" C'mon bro, this isn't 1999 anymore. Everyone has, at the very least, a mouse to select things.

The PromptBox is now better than ever! For even you FREDders! With the magic of scripted sexps, all that ugly script-eval stuff is a thing of the past. Now you just call a single sexp, and then check a single sexp for a response. And that's it!



Note to use scripted sexps, you need a nightly after January 19, 2018 (or 3.8.2 or 3.10 or 4.0 whatever the next official release number is)! The prompt box should be mostly backwards compatible if you already have it in your campaign. This version does not use any hud gauges, so it may look kind of small on monitor setups larger than 1080p. I'll figure out a way to fix that later...

SEE HERE ABOUT THE PROMPT BOX NOW

Includes a sample mission so you can see how the scripted sexp works.

Original Post Below...
Hidden Text: Show
This make this easier for everyone! (Click for video)


For those of you that didn't go "Did that years ago", there's a link at the end to all the files you'll need to set this up in your own campaign, including a test mission!

Here's how it works. The LUA script included just does the complicated stuff. It'll do all the hud gauge appearing and all the mouse stuff. It also has a function that FRED can take the line number that the player has just clicked. If you're fine with the included files, then you don't need to touch the lua script at all.

On the FRED side, you need to call different functions to activate certain parts of the script, set the custom gauge lines to whatever you like, and the mission logic to properly use everything together.

Custom HUD Gauges:
You can use set-hud-text or set-hud-message to have these gauges display text. The LUA script will take care of making them visible/invisible.
PromptBox - Use this to pose your choice to the player
PromptBoxOpt1
PromptBoxOpt2
PromptBoxOpt3 - Use these to let the player choose a response
PromptBoxOpt4
PromptBoxOpt5

LUA Script Functions to use in FRED:
Use these with script-eval:
proBoxInit() - Initialize the Prompt Box system. This is called on every gameplay start, so it shouldn't be required unless you need to reset everything for some reason.
proBoxAllowPause() - Will "pause" the game when the PromptBox is active. Actually this just slows the game down to 1% time compression, but it should give you plenty of time still.
proBoxDisallowPause() - Undoes the above
proBoxOn() - Forces the PromptBox to be on. If proBoxAllowPause() was called before, it will "pause" the game. This will also sort of steal your mouse focus. This is a lot more noticable when you do not have the pause option on.
proBoxOff() - Forces the PromptBox to be off. This will restore time compression and any other settings.
proBoxModeFree() - Puts PromptBox into free mode, where the player can call or dismiss the PromptBox with 'Alt-C' (Super note, this is NOT bindable, LUA doesn't care what is or isn't bound)
proBoxModeLock() - Undoes the above. This can be handy to temporarily lock out the player from bringing up the interface while you have a long talk session going.
proBoxSet(integer) - Sets the Prompt Box settings. The integer you put in between the brackets will be number of options that will be available to click. Inputting 1 through 5 will allow clicking on 1-5 lines. The lines are activated from the top going down. So proBoxSet(3) will make the top three lines clickable. An input of 0 will obviously not allow any clicking. An input of -1 is a shortcut, it will clear all the lines of text and reset time compression to normal. This is mostly used internally, though if you want to use it, go ahead.
proBoxLock(integer) - Allows you to lock a specific line (line integer). Stops it from being clickable, even if it would be allowed.
proBoxClear() - A shortcut that just clears all the text on the lines.

Use these with script-eval-num:
(These return values, to be used with arithmetic operators like '=')
proBoxValue() - Returns a value from 0 to 5. 1 through 5 if an allowable line has been clicked, 0 when nothing special has happened.
proBoxInFreeMode() - Returns 1 if you are in Free Mode, 0 if you are not.

Boy! That sounds like a LOT of work...

It's not really. Most of those functions are for the insane FREDders that want to pull off a free environment so they can talk to anyone at all.

If you want to use it in the most simple ways, just look in the included mission. From "CHOICE 1 - Choose Sidekick" to "Continuing On" is all you need to ask the player to make a simple choice.

If you want to use it in the most complicated ways... well... you can look in the mission and try to decipher what I did.

Basically what you want to keep in mind is "how can I make sure there is only one path to every response." You can do this through variables (to check who we are talking to), bit-wise operations (to check what options we've chosen before) and invisible mostly-unused stats like simulated hits (its a great ship-specific variable!). Another thing is to completely avoid using is-event-trues and chains in your repeating events. Beyond that... it's... kind of complicated. If you've got any specific questions on why I did certain things, I can certainly try to explain.

DOWNLOAD: http://lazymodders.fsmods.net/files/promptBox_V103.rar
Hidden Text: Show
« Last Edit: July 15, 2018, 02:23:35 pm by Axem »

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Prompt Box: An easy way to get a user response
sweet

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: Prompt Box: An easy way to get a user response
Now that's something plenty of modders will use, that's for sure.

inb4Freespace: the RPG
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
Re: Prompt Box: An easy way to get a user response
Whoa, so I'd seen this in a screenshot from you before but I never realized it actually paused the mission to force a response- that's pretty amazing. IIRC those training-msg choices are used a bit in BP...

 
Re: Prompt Box: An easy way to get a user response
Wow. This is incredible stuff. I... I still need to process all of this in. This kind of thing is precisely the type of thing I've been wanting to have for, years - and now it's here I think I need to completely rework a bunch of things I've already done for my mod. Thanks for the excellent work and release, Axem! (and anyone else who helped him, in case)
I'm all about getting the most out of games, so whenever I discover something very strange or push the limits, I upload them here:

http://www.youtube.com/user/JCDentonCZ

-----------------

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress to more pain."
- George Orwell

 

Offline BritishShivans

  • Jolly good supernova
  • 29
Re: Prompt Box: An easy way to get a user response
I wanted something like this. Training message stuff is cool and ****, but it's horrible for remapped keyboard stuff and etc. A mouse ignores all this stuff.

Thanks, Axem. You're awesome, and you should keep being awesome. Asides from JAD and other stuff, this is probably why I think of you as a FRED idol alongside Battuta. Now if only I'd get off my ass and keep practicing doing FRED stuff...  :nervous:

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
Download link has been updated with a bug fixed. proBoxLock() would give off an error about not being a number when it was. I had added some error checking at the last minute and copy pasted some code and didn't change the variable it was supposed to be looking at. All fixed now!

 
 

Offline fightermedic

  • 29
  • quite a nice guy, no really, i am
Re: Prompt Box: An easy way to get a user response
Who's up for a Freespace: Torment campaign? :P
what can change the nature of a spaceship?
>>Fully functional cockpits for Freespace<<
>>Ships created by me<<
Campaigns revised/voice-acted by me:
Lightning Marshal 1-4, The Regulus Campaign, Operation: Savior, Operation: Crucible, Titan Rebellion, Fall of Epsilon Pegasi 1.1Aftermath 2.1,
Pandora's Box 2.2, Deep Blood

Other Campaigns I have participated in:
The Antagonist, Warzone, Phantoms & Echo-Gate

All the stuff I release is free to use or change in any way for everybody who likes to do so; take whatever you need

 

Offline An4ximandros

  • 210
  • Transabyssal metastatic event
Re: Prompt Box: An easy way to get a user response
 I have seen Subspace move entire civilizations. I have seen Subspace forge empires that stretched as far as the universe has stars. And I have seen Subspace give life to beings who see themselves as more than a mere part of it.

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: Prompt Box: An easy way to get a user response
This is amazing, earlier today I was thinking about a similar feature relying on image subtitles rather than actual HUD gauges (which are way handier, IMO). :D My source of inspiration was FFXIII-2. Don't shoot me, please. :blah:
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline 666maslo666

  • 28
  • Artificial Neural Network
Re: Prompt Box: An easy way to get a user response
Is Prompt Box compatible with Cockpit Mod? When I use both the cockpit mod and prompt box, prompt box menu is invisible.

http://www.hard-light.net/forums/index.php?topic=84459
"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return." - Leonardo da Vinci

Arguing on the internet is like running in the Special Olympics. Even if you win you are still retarded.

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
That's pretty odd... I can't see why it would do that...

 

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
Re: Prompt Box: An easy way to get a user response


So, I'm getting a side effect here. After displaying the prompt box and getting a response, I (the player) can no longer set time compression in the mission. I cracked open the script and it seems like this happens because you're calling (set-time-compression 100) to reset it instead of (reset-time-compression), which unlocks the controls in addition to setting compression to 1x. I changed it and it works, but will there be any bugs if I'm using (reset-time-compression)?

Awesome script btw

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
Nah, that should be fine.


(And thanks!)

 
Re: Prompt Box: An easy way to get a user response
Question: What folder do I put the probox/line.eff files and what folder do I put the .png files? Completely clueless on where to put them.  :banghead:
Too many ideas.....not enough FREDing time!

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Prompt Box: An easy way to get a user response
I think they should all go in data/hud.
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 
Re: Prompt Box: An easy way to get a user response
Well I did some trial and error (why i didn't do that before I posted is beyond me.)
I put them in interface and its working fine with no problems and then I did the same with hud and no problems.
Does that mean it doesn't really matter?
If thats the case, apologies for necro-ing when I really should of just trial and errored.
Too many ideas.....not enough FREDing time!

 

Offline niffiwan

  • 211
  • Eluder Class
Re: Prompt Box: An easy way to get a user response
If it works in both then it really doesn't matter :)
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...