ID:268315
 
is there any way to do a check to see if an input box is open? Just curious, as I do a lot of menu icons (I use Click() a lot) which opens up input boxes consecutively, and I don't want people to click 2 different menu items and get 2 different inputs in a row...
You could always just try using a variable? Each button you click on checks to see if this variable (for all purposes, we will call 'var':P) is equal to 1. If it is, then simple cancel calling the procedure that will run the input, etc.

Quite obviously, you'd have 'var' set to 0, initially. Then, when someone clicks on an option it sets it to 1. They do all their stuff, then its set back to 0.

Example time,
mob/var/input_open = 0    // The variable we will use.

proc/ClicksAnOption()
if (src.input_open == 1) // Check to see if an input box is already open.
return 0 // If so, cancel the rest of the proc.
else // Otherwise...
src.input_open = 1 // Let the system know that it is open...
... // Do whatever here.
src.input_open = 0 // Let the system know that you've finished.
return 0


In this manner, people should only be able to have one input box open at a time, provided you remember to simply add the 'if ()' check there at the top.

Anyway, I hope I've been of any help.

-- Slipknight
In response to Slipknight
you have however I thought of this already... I guess I was just hoping of an easier method. It just so happens I didn't think of this when I was making my menu icons so now I have to go through a TON of code and put the var=0 whenever I use a return...

sigh, I'll give it one more day to see if someone comes up with a better way. :)
Jon Snow wrote:
is there any way to do a check to see if an input box is open? Just curious, as I do a lot of menu icons (I use Click() a lot) which opens up input boxes consecutively, and I don't want people to click 2 different menu items and get 2 different inputs in a row...

When an object is deleted, any procedure related to it will instantly stop. You can use this to your advantage, to keep input boxes open for a certain time period, or to check for the existance of input. A system might be something like this:

query
var/mob/owner
var/timer = -1 // -1 for no timer
var/key = ""
var/duplicate = 0 // 1 to enable duplicate queries
var/answer // answer stored here

New(mob/M,time = -1)
..()
if(!istype(M,/mob)) del src
if((key in M.queries) && duplicate) del src

owner = M
timer = time
owner.queries += "[src.key]"
owner.queries["[src.key]"] = src
get_input()

Del()
owner.queries -= src
..()

proc/get_input()


Now just override the get_input() procedure to ask for input:

query/mcdonalds
key = "mcdonalds"
get_input()
answer = input(owner,"How much McDonalds do you eat?") as text|message|null)


The above already prevents asking multiple times. You just have to remember to delete the /query after asking. A way of calling it:

var/query/Q = new/query/mcdonalds(src)
var/result = Q.answer
del Q


Granted this might be a bit overkill for your specific needs, but its a suggestion nontheless :)

This was written on-the-fly, so there might be something I didn't account for or catch. Im sort of in a hurry, on the way to an exam. But it should be workable.

Good luck,
Alathon