Author Topic: SCI0 [SOLVED] - Menubar with changing options  (Read 1648 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

SCI0 [SOLVED] - Menubar with changing options
« on: October 07, 2022, 12:19:49 PM »
I am trying to do one of two things and can't quite get either to work:
1. I am trying to make it so a cretain menu option either shows or doesn't based on a global variable. I have tried something like this, but doesn't seem to work:
Code: [Select]
(if aGlobalVariable
(AddMenu
{ Character -}
{Ask About`^a:Retype`#3:--!:Inventory`^I:Death Log`^d:Notes`^n:Switch`^x}
)
else
(AddMenu
{ Character -}
{Ask About`^a:Retype`#3:--!:Inventory`^I:Death Log`^d:Notes`^n}
)
)
It always gives me the AddMenu without the variable. So is there a command to update the menubar that I need to also do when I change the variable?

- or -
2. Can I show the option in the menubar at all times, but have the option "greyed" out and inactive unless the variable is true. This one I have no idea about at all, but just thought I'd ask anyway. I'd be happy to get either option running.
Thanks
« Last Edit: October 07, 2022, 02:13:46 PM by Doan Sephim »


Artificial Intelligence Competition

Offline doomlazer

Re: SCI0 - Menubar with changing options
« Reply #1 on: October 07, 2022, 12:46:10 PM »
Looks like SetMenu will enable/disable menu Items.

Code: [Select]
SetMenu(menuItem subFunction enable)
Enable:
Code: [Select]
SetMenu(Character AskAbout 1)

Disable:
Code: [Select]
SetMenu(Character AskAbout 0)

*Though I haven't tested and I'm not sure how you deal with that space in "ask about". Maybe that's causing problems?

Offline Doan Sephim

Re: SCI0 - Menubar with changing options
« Reply #2 on: October 07, 2022, 01:12:50 PM »
Thanks for the link to the info about SetMenu.

I tinkered around with it a bit...but haven't had any success with that one either.
« Last Edit: October 07, 2022, 01:21:50 PM by Doan Sephim »
Artificial Intelligence Competition

Offline doomlazer

Re: SCI0 - Menubar with changing options
« Reply #3 on: October 07, 2022, 01:47:01 PM »
Sorry, I had that wrong.

enable:
Code: [Select]
setMenu(AskAbout 112 1) ;

Disable:
Code: [Select]
setMenu(AskAbout 112 0) ;

I tested this in SQ3 and it worked:
Code: [Select]
(SetMenu quitI 112 0) ;disables quit
In SQ3 the p_state define is 112 as found in SYSTEM.SH, but that might be different in the template game.

Now determining what your "quitI" equivalent is could be a problem. In SQ3 quitI is defined in menu.sh. Are your menu items defined there as well?

« Last Edit: October 07, 2022, 01:52:29 PM by doomlazer »

Offline Doan Sephim

Re: SCI0 - Menubar with changing options
« Reply #4 on: October 07, 2022, 01:51:31 PM »
That's brilliant in that it does what I wanted most - the "greyed out" part...that said, I'm still not getting it to become usable when I change the variable...

This is what I am doing
Code: [Select]
(AddMenu
{ Character -}
{Ask About`^a:Retype`#3:--!:Inventory`^I:Death Log`^d:Notes`^n:Switch`^x}
)
(if gSwitchingAllowed
(SetMenu MENU_SWITCH 112 1)
else
(SetMenu MENU_SWITCH 112 0)
)

Offline doomlazer

Re: SCI0 - Menubar with changing options
« Reply #5 on: October 07, 2022, 01:55:28 PM »
Probably be cause the "if gSwitchingAllowed" check is only happening during the inital menu add and not when the variable changes?

I believe the new setMenu commands should be called every time gSwitchingAllowed is changed.
« Last Edit: October 07, 2022, 02:00:18 PM by doomlazer »

Offline Doan Sephim

Re: SCI0 - Menubar with changing options
« Reply #6 on: October 07, 2022, 02:13:22 PM »
Yup, just tried it and it work exactly as you have described.

Thanks for the help troubleshooting this. How did you find the 112 number? I don't think I'd ever had discovered that!

Offline doomlazer

!
« Reply #7 on: October 07, 2022, 02:50:56 PM »
YW. I tracked 112 down by using QfG2 and SQ3 as reference. Since you were using addMenu, I searched for it with SCICompanion's "Find in Files" and then looked at what they did. QFG2 uses "(SetMenu 1289 112 0)" to disable a menu item, but doesn't define 112 like SQ3 does. In SQ3 they don't disable menus, but they use "p_said" with setMenu, which is defined in system.sh as 109. Also defined is "p_state" as 112, which confirmed for me that 112 was the enable/disable subcommand mention in the scicompanion documentation.

Edit: I realized the SQ3 version I tested used the decompile archive source, while the QfG2 was a plain scicompanion decompile. Suddenly makes sense why SQ3 has "p_said" when QfG2 did not.
« Last Edit: October 07, 2022, 11:16:21 PM by doomlazer »


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

Page created in 0.031 seconds with 24 queries.