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

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.
Moderator: Moderators

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 14
Reputation: 13
Posts: 131
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: 19
Reputation: 77
Posts: 376
Joined: 26 Apr 2014
Location: Austria

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() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
Image
Wohlstand in interview:
Spoiler
Image

▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 14
Reputation: 13
Posts: 131
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: 19
Reputation: 77
Posts: 376
Joined: 26 Apr 2014
Location: Austria

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() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
Image
Wohlstand in interview:
Spoiler
Image

▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 14
Reputation: 13
Posts: 131
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: 25
Reputation: 317
Posts: 1292
Joined: 15 Feb 2014
Location: Moscow, Russia
Website Skype YouTube

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

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 14
Reputation: 13
Posts: 131
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: 19
Reputation: 77
Posts: 376
Joined: 26 Apr 2014
Location: Austria

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() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬
Image
Wohlstand in interview:
Spoiler
Image

▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬ Signature.end() ▬▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬

lighthouse64 M
Topic author, Duke
Duke
Avatar
lighthouse64 M
Topic author, Duke
Duke
Age: 14
Reputation: 13
Posts: 131
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: 1 guest