Post new topic    
Liquid Metal Slime
Send private message
making a text box disappear with ESC 
 PostWed Jan 29, 2014 1:28 am
Send private message Reply with quote
My game displays the hero's stats in a text box instead of the regular stats menu. Is there a way I can make that text box disappear when the player presses ESC as well as enter or spacebar?
Metal King Slime
Send private message
 
 PostWed Jan 29, 2014 11:03 am
Send private message Reply with quote
Use a script. Something containing

Code:
if (key is pressed(key:esc)) then (advance textbox)


For quite a while I've been thinking about making ESC advance text boxes. That is doesn't is inconsistent with everything else in the engine. I expect making that change would break scripts in several games, so it would have to be another general preference bitset. But I think it could default to being turned on in new games.
Liquid Metal King Slime
Send private message
 
 PostWed Jan 29, 2014 3:26 pm
Send private message Reply with quote
Hmmm... This seems like a good option.

I think it could break some of my scripts where a text box and a menu are being used at the same time, so I would probably leave it off in my own games, but turning it on by default in new games sounds fine to me.


Anyway, Willy, it is hard to say how long it will be before such a feature is ready, so here is an example of how to use TMC's "if key is pressed" suggestion

Code:

plotscript, show status box, begin
  show text box(5)
  while(current text box >= 0) do(
    if (key is pressed(key:esc)) then (advance textbox)
    wait(1)
  )
end
Liquid Metal Slime
Send private message
 
 PostThu Jan 30, 2014 2:36 am
Send private message Reply with quote
Cool. Thanks for your help guys. I figured I would have to use the "key is pressed" command, but I couldn't figure out how to use it in a loop.
Liquid Metal Slime
Send private message
 
 PostSat Feb 01, 2014 5:50 pm
Send private message Reply with quote
Here's my script, but it doesn't seem to be working. The text box still only closes with spacebar or return. As far as I can tell, none of the menu bitsets seem like they would affect it.

Code:
plotscript, status, begin
suspend player
show text box (33)
while(current text box >= 0) do(
    if (key is pressed(key:esc)) then (advance textbox)
)
wait for text box
open menu (0)
resume player
end
Liquid Metal King Slime
Send private message
 
 PostSat Feb 01, 2014 7:20 pm
Send private message Reply with quote
Oh, I think I see the problems.

First, Is that I forgot the "show text box" doesn't actually take effect until the next wait command, so you should add "wait(1)" right after the show text box

Next you need a "wait(1)" inside the "while" loop, otherwise the game will freeze up, because without a wait the keyboard will never be updated, so "key is pressed(key:esc)" won't be able to ever return true

Finally, remove the "wait for text box" because once you have the while loop working, it becomes redundant.

Code:

plotscript, status, begin
  suspend player
  show text box (33)
  wait(1)
  while(current text box >= 0) do(
      if (key is pressed(key:esc)) then (advance textbox)
      wait(1)
  )
  open menu (0)
  resume player
end


Let me know how that works.

Oh, actually, the "suspend player" and "resume player" are also not needed, because the player is always suspended automatically when you view a text box.
Metal King Slime
Send private message
 
 PostSun Feb 02, 2014 11:37 am
Send private message Reply with quote
Bob the Hamster wrote:
First, Is that I forgot the "show text box" doesn't actually take effect until the next wait command, so you should add "wait(1)" right after the show text box


Note that I've changed this in nightlies: there is now a backwards compatibility bitset called "showtextbox happens immediately", which is on by default in new games.
Blubber Bloat
Send private message
 
 PostSun Feb 02, 2014 6:31 pm
Send private message Reply with quote
TMC wrote:
Bob the Hamster wrote:
First, Is that I forgot the "show text box" doesn't actually take effect until the next wait command, so you should add "wait(1)" right after the show text box


Note that I've changed this in nightlies: there is now a backwards compatibility bitset called "showtextbox happens immediately", which is on by default in new games.


Sorslor though, I dig the updates you keep makin'
dOn'T MiNd mE! i'M jUsT CoNtAgIoUs!!!
Play Orbs CCG: http://orbsccg.com/r/4r6x V
Liquid Metal Slime
Send private message
 
 PostSun Feb 09, 2014 8:53 pm
Send private message Reply with quote
Bob the Hamster wrote:
Code:

plotscript, status, begin
  suspend player
  show text box (33)
  wait(1)
  while(current text box >= 0) do(
      if (key is pressed(key:esc)) then (advance textbox)
      wait(1)
  )
  open menu (0)
  resume player
end


Let me know how that works.


Sorry for the late reply. That worked like a charm.
Display posts from previous: