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

Description: Archive discussion
============================
Original description:
Official subforum for LunaLua - an extension framework for SMBX Engine Version 1.3 (which a core of SMBX 2.0). Share your creations that require the use of LunaLUA. You may also share info/tutorials on how to use LunaLUA.

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 21
Reputation: 19
Posts: 132
Joined: 15 Feb 2015
Location: IDK!

Post #1by lighthouse64 » 29 Jan 2016, 18:22

title says it all. I want to use it for something in an episode.
Player of hedgewars!!! :)
And hi... it's me from smbx
Currently bug testing for Mac :apple: And Windows :windows:

Kevsoft M
Angry developer
Angry developer
Avatar
Kevsoft M
Angry developer
Angry developer
Age: 25
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #2by Kevsoft » 30 Jan 2016, 18:35

Generally you can catch that with a pcall. But I wouldn't recommend debug message boxes as a gameplay element.
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 21
Reputation: 19
Posts: 132
Joined: 15 Feb 2015
Location: IDK!

Post #3by lighthouse64 » 31 Jan 2016, 14:36

It's the easiest way to ask a yes or no question :p Also, is pcall a global function?
Player of hedgewars!!! :)
And hi... it's me from smbx
Currently bug testing for Mac :apple: And Windows :windows:

Kevsoft M
Angry developer
Angry developer
Avatar
Kevsoft M
Angry developer
Angry developer
Age: 25
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #4by Kevsoft » 31 Jan 2016, 20:42

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
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 21
Reputation: 19
Posts: 132
Joined: 15 Feb 2015
Location: IDK!

Post #5by lighthouse64 » 5 Feb 2016, 16:31

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
Player of hedgewars!!! :)
And hi... it's me from smbx
Currently bug testing for Mac :apple: And Windows :windows:

Wohlstand M
Lead Developer
Lead Developer
Avatar
Wohlstand M
Lead Developer
Lead Developer
Age: 31
Reputation: 507
Posts: 1825
Joined: 15 Feb 2014
English Pronouns: he/him
Location: Moscow, Russia
Website Youtube channel URL Skype Tencent QQ

Post #6by Wohlstand » 5 Feb 2016, 18:23

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
Image

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 21
Reputation: 19
Posts: 132
Joined: 15 Feb 2015
Location: IDK!

Post #7by lighthouse64 » 13 Feb 2016, 16:30

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?
Player of hedgewars!!! :)
And hi... it's me from smbx
Currently bug testing for Mac :apple: And Windows :windows:

Kevsoft M
Angry developer
Angry developer
Avatar
Kevsoft M
Angry developer
Angry developer
Age: 25
Reputation: 93
Posts: 379
Joined: 26 Apr 2014
Location: Austria
Website

Post #8by Kevsoft » 14 Feb 2016, 0:08

woops, my bad:

Code: Select all

if pcall(function() windowDebug("LOL") end) then
  -- Success! No error
else
  -- Error! Probably hit "cancle"
end
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.start() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 21
Reputation: 19
Posts: 132
Joined: 15 Feb 2015
Location: IDK!

Post #9by lighthouse64 » 14 Feb 2016, 14:37

Thanks Kevsoft, It worked :)
Player of hedgewars!!! :)
And hi... it's me from smbx
Currently bug testing for Mac :apple: And Windows :windows:


Return to “LunaLua - Extension Framework”

Who is online (over the past 5 minutes)

Users browsing this forum: 2 guests