Page 2 of 2

Re: Gray Out / Disable User Interface?

Posted: Sun Nov 13, 2016 6:37 pm
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!

Re: Gray Out / Disable User Interface?

Posted: Sun Nov 13, 2016 6:58 pm
by Isaac

Re: Gray Out / Disable User Interface?

Posted: Mon Nov 14, 2016 8:43 am
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:

Re: Gray Out / Disable User Interface?

Posted: Tue Nov 15, 2016 4:40 am
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

Re: Gray Out / Disable User Interface?

Posted: Tue Nov 15, 2016 7:25 am
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:

Re: Gray Out / Disable User Interface?

Posted: Wed Nov 16, 2016 10:44 am
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 :)

Re: Gray Out / Disable User Interface?

Posted: Wed Nov 23, 2016 7:47 pm
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