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

0 Members and 1 Guest are viewing this topic.

Re: Prompt Box: An easy way to get a user response
So I've creating a simple mission based on Axem's checkpoint tutorial and the missions supplied with the shipsave and promptbox files. However upon starting my mission I get this error:

LUA ERROR: [string "promptBox-sct.tbm - On Game Init"]:80: attempt to index field 'Player' (a nil value)

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
Name:      (null)
Name of:   (null)
Function type:   (null)
Defined on:   0
Upvalues:   0

Source:      (null)
Short source:   
Current line:   0
- Function line:   0
------------------------------------------------------------------


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

stack traceback:
   [C]: ?
   [string "promptBox-sct.tbm - On Game Init"]:80: in function 'SetMsgGaugeVisible'
   [string "promptBox-sct.tbm - On Game Init"]:226: in function 'proBoxOff'
   [string "proBoxOff()"]:1: in main chunk
------------------------------------------------------------------

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

Normally I've been able to work these things out by myself but LUA stuff is rather foreign to me.
And Variables are very new to me so it might be something very obvious to the more experienced.

Edit: The prompt box works fine, it just comes up with this error upon start.
« Last Edit: February 12, 2014, 04:39:48 am by Boomer20 »
Too many ideas.....not enough FREDing time!

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
That's an annoying little bug that occurs when you try to turn the ProBox on exactly on mission start. Just tie the ProBox activation to a 1ms delay from mission start.

The reason why is that I try to lock the players weapons so they can click without firing but the player hook variable might not actually be ready on that first frame. I do plan to fix that issue in a v2 release.

 
Re: Prompt Box: An easy way to get a user response
I'm a little puzzled as why its occurring given I've set the prompt box to trigger when time-elapsed 1 second.
I've noticed playing my mission through that it only occurs when I start my mission and theres no save file for the checkpoint to trigger.
Once I've played through it and restarted it works fine until I go through the entire mission and reach the trigger that deletes the savefile. Then it goes back to giving the error.

EDIT: I've solved the problem, seems it was my Go to the start of the mission event. One of the triggers being the saveexist variable was set to zero when it was suppose to be 1. Granted it shouldn't have caused any problems anyway as no of the other event triggers were true but that seemed to be what the mission was tripping on.

EDIT2: That might have solved the when there's no savefile but when there is a savefile it trips up again. So I haven't fixed it. Given that it occurs straight away it seems as though it wants to activate the event the moment I start the mission even though it hasn't meet all the criteria. Any thoughts on whats wrong?
« Last Edit: February 12, 2014, 04:07:37 pm by Boomer20 »
Too many ideas.....not enough FREDing time!

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
The issue is also that proBoxOff() is probably getting called too early as well. That function, like proBoxOn(), needs the player hook variable to be active.

You can see how I set it up here.


So if there is no save that exists (which can occur before everything else is ready) AND a 1ms has elapsed (when we're all settled in), we can continue on our way.

Hope this helps!

 
Re: Prompt Box: An easy way to get a user response
Turns out when making it I missed the event-true after saveexist.  :banghead:
After that I got another problem of the promptbox not closing and breaking the mission but I worked that one out as well and it all works fine now.  :D
I like the prompt box and nice tutorial, a bit overwhelming when you first look at it, but after a few read throughs I managed to understand it, helped to learn about variables first though (which made it so much easier).
Thanks for the Help!
Too many ideas.....not enough FREDing time!

 
Re: Prompt Box: An easy way to get a user response
Apologies for the double post/ Necro but I've stumbled on a major bug in a mission that involves the prompt box.

So in my mission I use the prompt box 3 times. Once as a checkpoint option and twice as a method of branching the mission out. In all instances there are two options you can make. Heres where the issue is..........

If you choose Option 2 in all instances it will work fine no problems BUT if you choose Option 1 in all instances they all do the exact same thing. Which is rather annoying when you are at the checkpoint and you want to start the mission from the beginning and then instead it boots the mission into a stage that wasn't wanted.

Any suggestions and are the anyways I can trace this issue myself to track where it is going wrong. Like I said it only occurs on the first Options, not the second.
Too many ideas.....not enough FREDing time!

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
Are you using variables to keep track of what prompt you are giving the player? I usually have a variable that I set when I give a prompt and then for the resulting action its "when proBoxValue = X and question = Y."

Without seeing the mission I can't really say what the problem is for sure, but it sort of sounds like that is what's happening.

 
Re: Prompt Box: An easy way to get a user response
I am using variables and proBoxValue = X etc

Would it be easier for me to put the mission up and you have a look at all?
Too many ideas.....not enough FREDing time!

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
Yes, please. :) Or if you're worried about spoiling it, you can PM me a pastebin link!

 
Re: Prompt Box: An easy way to get a user response
Just PM'd you
Too many ideas.....not enough FREDing time!

 

Offline m!m

  • 211
Re: Prompt Box: An easy way to get a user response
While debugging the cursor behavior in antipodes I noticed that this script never calls io.setCursorHidden(true) after closing the prompt box. You might want to fix that :P

 

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
Actually because of the seemingly obtuse way that function worked (at least before), the variable it seemed to set would reset itself to true after the frame was done anyway. That's why io.setCursorHidden(false) had to be called every frame...

Is that going to change now?

 

Offline m!m

  • 211
Re: Prompt Box: An easy way to get a user response
We discussed this on IRC but I'll add it here for completeness.

Previously the state was reset every frame because :v: probably didn't bother putting the right calls at the various places in the code so it was handled in one place which set the mouse to be hidden when we are currently in the game play state. The approach of this script worked because the mouse was always drawn at the end of the frame so it didn't matter that the state switched from shown to hidden and back. Now that the OS is drawing the cursor (at least in antipodes) this leads to some complications because the point at which the cursor is drawn isn't determined by FSO anymore.

The solution for this particular problem is to just add a io.setCursorHidden(true) call when the PromptBox is closed. That will still be compatible with current builds and will also work with future antipodes builds.

  

Offline Axem

  • 211
Re: Prompt Box: An easy way to get a user response
I just made a large update to the Prompt Box. It now uses the same style used in JAD2.2 and WoD (using images instead of hud gauges) and as well, has the addition of SCRIPTED SEXPS. If you've used the prompt box in your campaign before, you'll know how much work it was to set up. Turn on all these hud gauges, set how many responses to do etc etc etc.

But now it's all just ONE SCRIPTED SEXP. JUST ONE. A MAZ ING.

You don't even need to keep track of questions through sexp variables, you just define a reference when calling it, and check to that same reference later!



(Note: nightly after Jan 19 2018 is needed!)

See original post for deets.