LoG Framework (dynamic hooks etc.)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Diarmuid »

Hi jKos and Xanathar, did you change something in how modules are loaded? Because the latest update seems to have broken exsp.

I use fw_addModule() to load a script entity A, then load a script entity B, and in B there is a method call to A which fails. Are all modules put into a table and then loaded later in a random order, or something like that? What has changed?
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

New version:
- script entities are now spawned in same order as they are loaded by calling fw_loadModule.

(this should fix that problem with exsp)
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Diarmuid »

Ah, great, thanks so much and sorry for the trouble.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

New version again.

- Added support for party.onDrawGui, onDrawInventory, onDrawStats and onDrawSkills-hooks

some useless usage examples:

Code: Select all


function autoexec()
	fw.setHook('party.myHook.onDrawGui',function(g)
			g.color(0, 0, 0)
			g.drawRect(10, 10,100, 100)
		end
	)
	fw.setHook('party.myOtherHook.onDrawGui',function(g)
			g.color(255, 255, 255)
			g.drawRect(110, 110,100, 100)
		end
	)
	fw.setHook('party.myInventoryHook.onDrawInventory',function(g,champion)
			g.color(255, 255, 255)
			g.drawText(champion:getName(),110,130)
		end
	)
end
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Diarmuid »

Remind me if I'm wrong, but for dynamic hooks to work, there must not be an object defined with that hook in an .lua, because it overrides the framework calls, right?

So if nothing must ever define it's onDraw hooks "hardcoded", then we need new versions of things like grimwidgets, because right now if grimwidgets is installed, those new framework hooks do nothing.

I went ahead for the ORRR2, removed the party definition from grimwidgets.lua, and added the following to gw.lua:

Code: Select all

function autoexec()

	fw.setHook('party.gw.onDrawGui', function(g)
			gw._drawGUI(g)
		end
	)

	fw.setHook('party.gw.onDrawInventory', function(g,champ)
			gw._drawInventory(g,champ)
		end
	)

	fw.setHook('party.gw.onDrawSkills', function(g,champ)
			gw._drawSkills(g,champ)
		end
	)

	fw.setHook('party.gw.onDrawStats', function(g,champ)
			gw._drawStats(g,champ)
		end
	)

end
Eventually grimQ should also be updated to support those new hooks for the autohook feature (right now it doens't work)
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Xanathar »

@JKos: thanks!!

@Diarmuid:
grimQ should also be updated to support those new hooks for the autohook feature (right now it doens't work)
This is strange because for my dungeon I was using a modified framework which was already forwarding onDrawGui and using autohooks without hassles. But then, I might have some minor change I forgot somewhere in my grimq so I wouldn't bet my hand on it.
Later today I check.
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
Gotcha!
Posts: 19
Joined: Sat Jul 14, 2012 10:43 pm

Re: LoG Framework (dynamic hooks etc.)

Post by Gotcha! »

Hi there,

Would you mind a question?

I am a real nincompoop when it comes to lua and this framework thing utterly hurts my mind as well.
I've got the framework installed and it probably works, but I have no idea how to make a hook/script that makes my party members talk.
Does any of you perhaps have an example?

I take it that I just need to place a new script item in the editor and paste the hook in there?
But pasting stuff like

Code: Select all

talk.addTalkHook('snail_1','onDie','Take that slimeball!',1)
talk.addTalkHook('round_shield_1','onPickUp','This will be useful.',0.5)
return opener.name == 'party'  
end
)
doesn't work.

I hope you can help! I am creating a huge dungeon where the party members are required to do a lot of talking.
(By the by, if anyone would know of a way to make them talk without this framework then I'd be happy too. Lua is already an impossible thing for me to grasp. I don't like to overcomplicate things for myself. ^_^')
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by JKos »

Hi,

just add a function named autoexec to any script entity and put your hooks there.

Code: Select all

function autoexec()
    talk.addTalkHook('snail_1','onDie','Take that slimeball!',1)
end
the autoexec function is executed automatically after the framework is loaded.
Now when you kill the snail_1 it should print
Random Champion Name: Take that slimeball!

EDit: you also have to load the talk module by adding this line to your init.lua

Code: Select all

fw_loadModule('talk')
after this line:
import "mod_assets/framework/framework.lua"
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Gotcha!
Posts: 19
Joined: Sat Jul 14, 2012 10:43 pm

Re: LoG Framework (dynamic hooks etc.)

Post by Gotcha! »

Thank you! That function autoexec() code was exactly what I needed. :)
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: LoG Framework (dynamic hooks etc.)

Post by Xanathar »

Hi JKos
I did some perf test, and it seems routing onDrawGui (and friends) through the framework causes a bad slowdown of everything (even if nothing is registered) for some reason. The slowdown is visible only in a dungeon with many many objects - don't know the reason, but I know dispatching gui without the framework actually improves my mod performance a lot. Still investigating this, if I find further details I'll tell you.

My fault for suggesting adding them :( sorry
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
Post Reply