Author Topic: SCI0 - How to check if right-click on a control color?  (Read 653 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

SCI0 - How to check if right-click on a control color?
« on: January 04, 2022, 02:04:29 PM »
I've actually never done this before. I've only verified for clicking within a box or on a view's box dimensions.
I tried something like:
Code: [Select]
(method (handleEvent pEvent)
(super handleEvent: pEvent)
(if (== (pEvent type?) evMOUSEBUTTON)
(if (& (pEvent modifiers?) emRIGHT_BUTTON)
(if (== pEvent ctlFUCHSIA)

But that doesn't return true

I also tried
Code: [Select]
(if (pEvent onControl: ctlFUCHSIA)and
Code: [Select]
(if (== (pEvent onControl: ctlFUCHSIA) TRUE)But both crash the game because I clearly don't know the proper syntax for this.

I know a lot of this is common knowledge for people who have looked through decompiled scripts, but every time I've tried that, I end up more confused than ever!


Artificial Intelligence Competition

Offline Kawa

Re: SCI0 - How to check if right-click on a control color?
« Reply #1 on: January 04, 2022, 02:20:44 PM »
I also tried
Code: [Select]
(if (pEvent onControl: ctlFUCHSIA)and
Code: [Select]
(if (== (pEvent onControl: ctlFUCHSIA) TRUE)But both crash the game because I clearly don't know the proper syntax for this.
It's not a syntax thing, Event has no onControl no matter how you try to invoke it.

What you want to use instead is the OnControl kernel call. Pass it the x and y from your event and you're set.

Offline Doan Sephim

Re: SCI0 - How to check if right-click on a control color?
« Reply #2 on: January 04, 2022, 03:56:13 PM »
Thanks. I found something like this from an old post from 2012. It's not Sierra Script, but it looks roughly like what you're talking about

Code: [Select]
== $0002 OnControl(ocPRIORITY (send pEvent:x) (send pEvent:y)) I'm still trying to get it sorted, but is this the right direction to head?

EDIT:

I think I've got it working properly, thanks to your advice and the aforementioned quote from gumby.
I'm using this and it seems to get the job done:
Code: [Select]
(if (== (OnControl ocSPECIAL (pEvent x?) (pEvent y?)) ctlFUCHSIA)
« Last Edit: January 04, 2022, 04:07:22 PM by Doan Sephim »
Artificial Intelligence Competition

Offline Kawa

Re: SCI0 - How to check if right-click on a control color?
« Reply #3 on: January 05, 2022, 05:42:28 AM »
That's exactly it! Now, if you want to check the same click for a bunch of different colors, you might want to do the OnControl call once, stuff the result in a temporary variable, and then compare that variable against all the different colors.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.097 seconds with 25 queries.