Gray Out / Disable User Interface?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Gray Out / Disable User Interface?

Post by AndakRainor »

Warning:

PartyComponent.onClickItemSlot(self, champion, container, slot, button) => champion is nil if you click on the attack panel's hands

your hook could cause a crash!
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Gray Out / Disable User Interface?

Post by Isaac »

User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Gray Out / Disable User Interface?

Post by akroma222 »

AndakRainor wrote:Warning:
PartyComponent.onClickItemSlot(self, champion, container, slot, button) => champion is nil if you click on the attack panel's hands
your hook could cause a crash!
Apologies folks - thanks again AndakRainor :oops:
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Gray Out / Disable User Interface?

Post by Lark »

I've been silent here a bit because 1) I'm working too much [I hate it when "life" gets in the way!], and 2) I'm more than a bit lost. I've never done "party hooks", so I'm searching the forums for a simple example that I can use. There are a lot of posts on them, but I'm missing some basic information, I think.

But then, if I understand the previous posts any at all, I can create one or more party hooks when the party "attack panel" is rendered on the screen and I can affect it on each frame so that it is modified how I want, namely grayed out for a time. Am I on the right track? Sorry to be such a newb here, but I' learning!

Thanks, -Lark
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Gray Out / Disable User Interface?

Post by Isaac »

The supported hooks in Grimrock 1 & 2 are in their respective scripting references. [Essentially] If defined they exist; if they exist, they get called when their event triggers. Many of them have the option of canceling the calling event. This is done by returning a value of False. For instance, by returning false from the party:onMove() hook, the party does not complete the movement that triggered the hook. In another instance, the onAcceptItem() hook for a surface component, cancels the acceptance of the item, if the hook function returns false.

Defining a hook is done by including it as a variable in the component, and assigning an anonymous function to it.
eg. onMove = function(self) -- instructions here get called before every move -- end

*technical corrections follow... :mrgreen:
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Gray Out / Disable User Interface?

Post by akroma222 »

Hey Lark,
Isaac's explanation is spot on, and yes you are right - they are really essential to at least understand
Here is a list of the party hooks (from jKos wiki, also in scripting reference)
SpoilerShow

Code: Select all

 
PartyComponent.onCastSpell(self, champion, spell)
PartyComponent.onClickItemSlot(self, champion, container, slot, button) Beta 2.2.4
PartyComponent.onDamage(self, champion, damage, damageType)
PartyComponent.onDie(self, champion)
PartyComponent.onAttack(self, champion, action, slot)
PartyComponent.onGetPortrait(self,champion) Beta 2.2.3
PartyComponent.onLevelUp(self, champion)
PartyComponent.onReceiveCondition(self, champion, condition)
PartyComponent.onDrawAttackPanel(self, champion, context, x, y) Beta 2.2.4
PartyComponent.onDrawGui(self, context)
PartyComponent.onDrawInventory(self, context, champion)
PartyComponent.onDrawStats(self, context, champion)
PartyComponent.onDrawSkills(self, context, champion)
PartyComponent.onDrawTraits(self, context, champion)
PartyComponent.onPickUpItem(self, item)
PartyComponent.onProjectileHit(self, champion, item, damage, damageType)
PartyComponent.onRest(self)
PartyComponent.onWakeUp(self)
PartyComponent.onTurn(self, direction)
"direction" will be -1 for a left turn, or 1 for a right turn
PartyComponent.onMove(self, direction)
If you want some examples to read over/work with - Id be happy to send you my lua file with all my party hooks (so far)
Let me know if so :)
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Gray Out / Disable User Interface?

Post by Lark »

Isaac and Akroma: Thank you very much for the assistance. This helps me understand what's happening a bit better and I can't wait to play with it when I get some time which is way to hard to come by lately. You two are very kind.

Akroma: I would LOVE to have your party hooks - working examples really help me a lot. I'll PM you an email address.

Sincere thanks to you both! -Lark
Post Reply