Page 1 of 1

How to check if someone has clicked ok or cancel on a debug box

Posted: 29 Jan 2016, 18:22
by lighthouse64
title says it all. I want to use it for something in an episode.

Posted: 30 Jan 2016, 18:35
by Kevsoft
Generally you can catch that with a pcall. But I wouldn't recommend debug message boxes as a gameplay element.

Posted: 31 Jan 2016, 14:36
by lighthouse64
It's the easiest way to ask a yes or no question :p Also, is pcall a global function?

Posted: 31 Jan 2016, 20:42
by Kevsoft
lighthouse64 wrote:How to check if someone has clicked ok or cancel on a debug box
I wouldn't answer a "How to"-Question with a yes or no.

lighthouse64 wrote:Also, is pcall a global function?
pcall is a global lua function:

Code: Select all

if pcall(windowDebug("LOL")) then
  -- Success! No error
else
  -- Error! Probably hit "cancle"
end

Posted: 5 Feb 2016, 16:31
by lighthouse64
Ok, So I tried this code, but when I press ok, it's seems to go to the else part of the if/else statement. The cancel button still pops up with the message saying that I pressed cancel on debug.

Code: Select all

function onLoad()
if pcall(windowDebug("Are you a nice person?")==true) then
windowDebug("you are invited!")
else
windowDebug("Die.")
end
end

Posted: 5 Feb 2016, 18:23
by Wohlstand
I think. you just accidentally mistook with brekets

Code: Select all

function onLoad()
   if(pcall(windowDebug("Are you a nice person?"))==true)then
        windowDebug("you are invited!")
   else
       windowDebug("Die.")
   end
end

Posted: 13 Feb 2016, 16:30
by lighthouse64
Idk why, but for some reason I got an error when putting the code in.
Image
am I supposed to define pcall as something first?

Posted: 14 Feb 2016, 0:08
by Kevsoft
woops, my bad:

Code: Select all

if pcall(function() windowDebug("LOL") end) then
  -- Success! No error
else
  -- Error! Probably hit "cancle"
end

Posted: 14 Feb 2016, 14:37
by lighthouse64
Thanks Kevsoft, It worked :)