LoG Framework (dynamic hooks etc.)
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Ok, I added a working flame arrow example to here: https://sites.google.com/site/jkosgrimr ... l-fw_magic
Lot's of things are still missing but I hope you will get the idea. Any feedback is welcome.
Lot's of things are still missing but I hope you will get the idea. Any feedback is welcome.
- 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
- cloneObject viewtopic.php?f=22&t=8450
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Hi JKos,
Is there a way to delay the return of a function?
I'm trying to code a level, x, y, facing = getTeleportTarget(id) function which would return the target of a teleporter (unless I've missed this already somewhere?)
I thought of spawning a probe item on the teleporter then checking it's location. Problem is I need a delay so that it gets teleported, so I cannot just spawn and destroy it right away.
If I wrap the test code in one of your timers callbacks however, how can I return a value to the main function? Simplified example:
The above won't work because we'll get to the return code 0.05s before the callBack is called. But if I return from within the call back, it will return to the callCallbacks, right?
Thanks in advance for the help...
Is there a way to delay the return of a function?
I'm trying to code a level, x, y, facing = getTeleportTarget(id) function which would return the target of a teleporter (unless I've missed this already somewhere?)
I thought of spawning a probe item on the teleporter then checking it's location. Problem is I need a delay so that it gets teleported, so I cannot just spawn and destroy it right away.
If I wrap the test code in one of your timers callbacks however, how can I return a value to the main function? Simplified example:
Code: Select all
function getTeleportTarget(id)
-- spawn item on teleporter here
timer:addCallcack in 0.05s(
function(
-- test for location here
end
)
-- return value based on test inside call back
end
Thanks in advance for the help...
Re: LoG Framework (new: AD&D style spell book and 14 spells)
I can see your problem, but unfortunately there is no way to delay the function return or pause the code. So you have to use callback for handling the return value.
Not sure if this is a solution to your problem.
Edit: fixed the code
Code: Select all
function getTeleportTarget(id,returnCallback)
-- spawn item on teleporter here
timer:setTimerInterval(0.05)
timer.returnCallback = returnCallback
timer:addCallback(
function(self)
-- test for location here
self.returnCallback(level,x,y,facing)
end
)
-- return value based on test inside call back
end
handleReturnValue = function(level,x,y,facing)
-- target values are returned to this function
-- so you can do your stuff here
end
getTeleportTarget('teleporter_1',handleReturnValue)
Edit: fixed the code
- 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
- cloneObject viewtopic.php?f=22&t=8450
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Hmm... I did not know you could pass functions as arguments, interesting.
In your code however, why would you pass the function as an argument and define it as an entry in the timer properties table? Isn't it equivalent to:
The above being the whole structure of functions calling themselves in loops within callbacks I use in my spells script. What am I missing?
Anyway, after thinking a bit more about it, I dropped the idea of automatically get a teleporter id - there's no reliable way to do it. It was for a particular spinner object, but people will have to provide the target manually.
In your code however, why would you pass the function as an argument and define it as an entry in the timer properties table? Isn't it equivalent to:
Code: Select all
function getTeleportTarget(id)
-- spawn item on teleporter here
timer:setTimerInterval(0.05)
timer:addCallback(
function(self)
-- test for location here
handleReturnValue(level,x,y,facing)
end
)
-- return value based on test inside call back
end
handleReturnValue = function(level,x,y,facing)
-- target values are returned to this function
-- so you can do your stuff here
end
getTeleportTarget('teleporter_1')
Anyway, after thinking a bit more about it, I dropped the idea of automatically get a teleporter id - there's no reliable way to do it. It was for a particular spinner object, but people will have to provide the target manually.
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Yes it basically the same, but my solution is more generally usable: You can write multiple returnValueHandlers.
But anyway I uploaded a new version:
V0.9.5 (2012-12-12)
- GrimQ included as a core module (Thanks to Xanathar who is the author of this really great and useful library)
GrimQ is loaded automatically, but you can also copy paste the GrimQ code to the dungeon and the framework will not load the included version. For example if you want to use a newer version than the included one. See: https://sites.google.com/site/jkosgrimr ... dule-grimq
- Documentation improved. IMO it's now much clearer and easier to read. (Found a table of contents widget from Google sites, and I have to say that Google sites rocks, really nice and FREE service)
But anyway I uploaded a new version:
V0.9.5 (2012-12-12)
- GrimQ included as a core module (Thanks to Xanathar who is the author of this really great and useful library)
GrimQ is loaded automatically, but you can also copy paste the GrimQ code to the dungeon and the framework will not load the included version. For example if you want to use a newer version than the included one. See: https://sites.google.com/site/jkosgrimr ... dule-grimq
- Documentation improved. IMO it's now much clearer and easier to read. (Found a table of contents widget from Google sites, and I have to say that Google sites rocks, really nice and FREE service)
- 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
- cloneObject viewtopic.php?f=22&t=8450
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Hi,
I have a question. In your guidelines, you mention that in init.lua, the framework should be imported after standard_assets.lua. However, I've noticed that if I want the hooks shortcut "monsters" to apply to custom monsters as well, I had to import framework.lua after all custom assets and add custom monsters to lists.monster in fw.lua (so that they get cloned properly).
Is there another way to do this that I've missed?
I have a question. In your guidelines, you mention that in init.lua, the framework should be imported after standard_assets.lua. However, I've noticed that if I want the hooks shortcut "monsters" to apply to custom monsters as well, I had to import framework.lua after all custom assets and add custom monsters to lists.monster in fw.lua (so that they get cloned properly).
Is there another way to do this that I've missed?
Re: LoG Framework (new: AD&D style spell book and 14 spells)
I have a new version ready to be uploaded which adds automatic support for custom monsters and other assets, so you don't anymore have to add them to monsters lists (thanks to Xanathars grimq). I will upload it soon, but I think i'm testing a new LoG version a while. So much to do and so little time...
- 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
- cloneObject viewtopic.php?f=22&t=8450
Re: LoG Framework (new: AD&D style spell book and 14 spells)
Nice to see there is yet some more improvement to the framework !
I don't know if I should post this here but since it regards the casting and fighting system...
I had some weird ideas regarding spells yesterday.
Do you think it would be hard to add incantation sound/chant to every spells ?
Spell casting is kinda like shooting an arrow right now (the runes apart) and that's weird.
You could think of a similar system for the other character fighting method also.
Warrior shoutin/screaming while swinging their weapons, rogues sighing while throwing weapons or using projectiles, etc.
If this can be done and if this is not a performance killer, that could add some nice atmosphere to the fighting system don't you think ?
This may be a bad idea, I d'ont really know...
I don't know if I should post this here but since it regards the casting and fighting system...
I had some weird ideas regarding spells yesterday.
Do you think it would be hard to add incantation sound/chant to every spells ?
Spell casting is kinda like shooting an arrow right now (the runes apart) and that's weird.
You could think of a similar system for the other character fighting method also.
Warrior shoutin/screaming while swinging their weapons, rogues sighing while throwing weapons or using projectiles, etc.
If this can be done and if this is not a performance killer, that could add some nice atmosphere to the fighting system don't you think ?
This may be a bad idea, I d'ont really know...
Re: LoG Framework (new: AD&D style spell book and 14 spells)
That shouldn't be too difficult to implement using party hooks... e.g.
You'd need a sound sample for each incantation and a definition in sounds.lua for each.
same could be done for onAttack.. either based on what weapon is used, or which champion is attacking.
Who can forget the classic DM warcry... yeeearrrgghh!
Code: Select all
onCastSpell(champ,spell)
if spell == "fireball" then
playSound("incantation_1")
elseif spell == "fireburst"
playSound("incantation_2")
end
return true
end
same could be done for onAttack.. either based on what weapon is used, or which champion is attacking.
Who can forget the classic DM warcry... yeeearrrgghh!
SpoilerShow
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: LoG Framework (new: AD&D style spell book and 14 spells)
New version with better custom assets support. Not perfect yet, but at least you don't have to modify the fw.lua anymore 
https://sites.google.com/site/jkosgrimr ... tom-assets
Dynamic hooks with custom assets
All custom assets should be included after the framework.lua or otherwise the dynamic hooks won't work with them. All cloned objects should work out of the box, but if you have created totally new assets with defineObject, you have to call fw_addHooks-function after the defineObject, IF you want to use dynamic hooks with it.
fw_addHooks(entityName,entityType,[itemSubtype])
Entity types: monster,item,alcove,blockage,door
ItemSubtypes: weapon, shield,accessory,bomb,food, missileweapon, tome,armor,cloth,herb,machinepart,potion,staff,treasure,container,key,miscitem,scroll, custom
itemSubtype defines the hook-namespace for the item and is used on various help-module functions (eg. checkType). Default value is 'custom'.
Examples

https://sites.google.com/site/jkosgrimr ... tom-assets
Dynamic hooks with custom assets
All custom assets should be included after the framework.lua or otherwise the dynamic hooks won't work with them. All cloned objects should work out of the box, but if you have created totally new assets with defineObject, you have to call fw_addHooks-function after the defineObject, IF you want to use dynamic hooks with it.
fw_addHooks(entityName,entityType,[itemSubtype])
Entity types: monster,item,alcove,blockage,door
ItemSubtypes: weapon, shield,accessory,bomb,food, missileweapon, tome,armor,cloth,herb,machinepart,potion,staff,treasure,container,key,miscitem,scroll, custom
itemSubtype defines the hook-namespace for the item and is used on various help-module functions (eg. checkType). Default value is 'custom'.
Examples
Code: Select all
defineObject{
name='snail_king',
class = 'Monster',
...
}
fw_addHooks('snail_king','monster')
defineObject{
name='my_super_weapon',
class = 'Item',
...
}
fw_addHooks('my_super_weapon','item','weapon')
- 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
- cloneObject viewtopic.php?f=22&t=8450