Page 1 of 1

Party scripting hooks

Posted: Wed Oct 22, 2014 5:36 pm
by Jgwman
I never messed with the scripting hooks for the party in LoG 1; can someone explain to me in which lua file you defined the callbacks for party hooks in LoG 1, and an example?

Re: Party scripting hooks

Posted: Wed Oct 22, 2014 6:28 pm
by SnowyOwl47
Jgwman wrote:I never messed with the scripting hooks for the party in LoG 1; can someone explain to me in which lua file you defined the callbacks for party hooks in LoG 1, and an example?
party_hooks.lua we created our own file then imported it in the init.lua

But in the party_hooks.lua we had to define the party and add somethings:

viewtopic.php?f=14&t=5803&hilit=+hook

But that is just for LOG1 we'd have to port it over to LOG2

Re: Party scripting hooks

Posted: Wed Oct 22, 2014 6:49 pm
by Jgwman
Cool. I'll look into it tonight. Thanks.

Re: Party scripting hooks

Posted: Thu Oct 23, 2014 10:24 pm
by JKos
I made some quick testing with old party hook-names and here are the results (and an example of defining party-hooks):
Main difference to LoG1 is that all hooks receive party-object as a first argument.
(And you can define objects in any .lua file which is imported to init.lua)

Code: Select all

defineObject{
   name = "party",
   baseObject = "party",
   components = {
      {
        class = "Party",
		-- WORKS
		onMove = function(party,dir,arg1) 
			print(party.go.id,"moving to",dir) 
		end,
		-- WORKS
		onTurn = function(party,dir,arg1) 
			print(party.go.id,"turning to",dir) 
		end,
		-- WORKS (NOT with bare hands)
		onAttack = function(party,champion,weapon) 
			print(champion:getName(),'is attacking with',weapon.go.id) 
		end,
		-- WORKS
		onDamage = function(party, champion,damage,damageType) 
			print(party.go.id, champion:getName(), 'received damage', damage,damageType) 
		end,
		-- WORKS
		onProjectileHit = function(party,champion,projectile,damage,damageType) 
			print(party.go.id,champion:getName(),'is hit by a',projectile.go.name,damage,damageType) 
		end,				
		-- WORKS
		onDie = function(party,champion) 
			print(party.go.id,champion:getName(),'died') 
		end,
		-- WORKS
		onRest = function(party) 
			print(party.go.id,'is resting') 
		end,
		-- WORKS
		onWakeUp = function(party) 
			print(party.go.id,'woke up') 
		end,
		-- NOT WORKING (Also tested onDrawUI,onDrawGUI,onDraw,onDrawAll but no luck)
		onDrawGui = function(g) print('gui') end, 
		-- WORKS
		onDrawInventory = function(g,champion) 
			--print('inventory') 
		end, 
		-- WORKS
		onDrawStats = function(g,champion) print('stats') end, 
		-- NOT WORKING
		onDrawSkills = function(g,champion) print('skills') end, 
		-- NOT WORKING
		onDrawTraits = function(g,champion) print('traits') end, 
		
		-- UNTESTED

		onUseItem = function(party,champion,item,slot) 
			print(party.go.id,champion:getName(),'is using',item,slot) 
		end,		
		onReceiveCondition = function(party,champ,condition,condNumber) end, 
		onCastSpell = function(party,champion,spellName) end,
		onLevelUp = function(party,champion) end,
		onPickUpItem = function(party,item) end
      }
   },
}


Re: Party scripting hooks

Posted: Thu Oct 23, 2014 10:37 pm
by Jgwman
JKos wrote:I made some quick testing with old party hook-names and here are the results (and an example of defining party-hooks):
Main difference to LoG1 is that all hooks receive party-object as a first argument.
(And you can define objects in any .lua file which is imported to init.lua)

Code: Select all

defineObject{
   name = "party",
   baseObject = "party",
   components = {
      {
        class = "Party",
		-- WORKS
		onMove = function(party,dir,arg1) 
			print(party.go.id,"moving to",dir) 
		end,
		-- WORKS
		onTurn = function(party,dir,arg1) 
			print(party.go.id,"turning to",dir) 
		end,
		-- WORKS (NOT with bare hands)
		onAttack = function(party,champion,weapon) 
			print(champion:getName(),'is attacking with',weapon.go.id) 
		end,
		-- WORKS
		onDamage = function(party, champion,damage,damageType) 
			print(party.go.id, champion:getName(), 'received damage', damage,damageType) 
		end,
		-- WORKS
		onProjectileHit = function(party,champion,projectile,damage,damageType) 
			print(party.go.id,champion:getName(),'is hit by a',projectile.go.name,damage,damageType) 
		end,				
		-- WORKS
		onDie = function(party,champion) 
			print(party.go.id,champion:getName(),'died') 
		end,
		-- WORKS
		onRest = function(party) 
			print(party.go.id,'is resting') 
		end,
		-- WORKS
		onWakeUp = function(party) 
			print(party.go.id,'woke up') 
		end,
		-- NOT WORKING (Also tested onDrawUI,onDrawGUI,onDraw,onDrawAll but no luck)
		onDrawGui = function(g) print('gui') end, 
		-- WORKS
		onDrawInventory = function(g,champion) 
			--print('inventory') 
		end, 
		-- WORKS
		onDrawStats = function(g,champion) print('stats') end, 
		-- NOT WORKING
		onDrawSkills = function(g,champion) print('skills') end, 
		-- NOT WORKING
		onDrawTraits = function(g,champion) print('traits') end, 
		
		-- UNTESTED

		onUseItem = function(party,champion,item,slot) 
			print(party.go.id,champion:getName(),'is using',item,slot) 
		end,		
		onReceiveCondition = function(party,champ,condition,condNumber) end, 
		onCastSpell = function(party,champion,spellName) end,
		onLevelUp = function(party,champion) end,
		onPickUpItem = function(party,item) end
      }
   },
}

Thanks JKos! That's great!

Re: Party scripting hooks

Posted: Thu Oct 23, 2014 10:56 pm
by cromcrom
Yep, thanks a lot JKos

Re: Party scripting hooks

Posted: Thu Oct 23, 2014 11:12 pm
by NutJob
Fantastic! Appreciation Station!

Is anyone aware of an event that's triggered by putting an item into inventory? event(p,champ,item)

I've tried quite a few now: onDropItem, onDropItemInventory, onSetDownItem, onAquireItem plus a few more embarrassing ones. =)