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 (new: AD&D style spell book and 14 spells)

Post by Diarmuid »

Great, thanks for the fix, and sorry for the equip/unEquip fuss... ;)
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: LoG Framework (new: AD&D style spell book and 14 spells)

Post by Grimfan »

Okay, my first time trying out the LoG framework (there's so much it's difficult to comprehend it all) but I've run into a problem at the outset.

I put the script entity logfw_init on the first level of my dungeon and pasted in the following code:

Code: Select all

spawn("LoGFramework", party.level,1,1,0,'fwInit')
fwInit:open() 
-- timer will call this method automatically  0.1 seconds after the game is started
function main()
   fw.debug.enabled = false
   fwInit:close() --must be called
end
 
but as soon as I run preview mode I get this error message:

bad argument #1 to 'pairs'(table expected, got nil) X

So, what's going on?

PS. Everything else has been loaded per instructions. I also have Xanathar's chestmanager scripts, Diarmuid's exsp spells, his damagetracker script and his and Neikun's crystalHandler script in play (wow, just realized how much of my dungeon relies on Diarmuid's sheer brilliance) and a few other minor scripts here and there.

PPS. Is this problem because I didn't use the Jkos framework from the beginning of my dungeon?
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: LoG Framework (new: AD&D style spell book and 14 spells)

Post by JKos »

It's pretty hard to say since you have so much stuff installed.
Could you copy paste your init.lua here?

And did I uderstood correctly that you already have exsp working in your dungeon? If so, you must also have my framework succesfully installed already, because as far as I know the exsp requires it.
So could it be so that you have installed my framework twice? :)
- 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
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: LoG Framework (dynamic hooks etc.)

Post by Grimfan »

Sorry, I actually downloaded the exsp at the same time I downloaded your framework, so while your framework may be outstanding I haven't downloaded it twice. :P

Here's the entry in my init.lua:

-- This file has been generated by Dungeon Editor 1.3.7

-- import standard assets
import "assets/scripts/standard_assets.lua"

--import framework
import "mod_assets/framework/framework.lua"

-- import custom assets
import "mod_assets/scripts/items.lua"
import "mod_assets/scripts/monsters.lua"
import "mod_assets/scripts/objects.lua"
import "mod_assets/scripts/wall_sets.lua"
import "mod_assets/scripts/recipes.lua"
import "mod_assets/scripts/spells.lua"
import "mod_assets/scripts/materials.lua"
import "mod_assets/scripts/sounds.lua"
import "mod_assets/sx_water_fountains_scripts/sx_waterfountains.lua"
import "mod_assets/merethif_shields/scripts/items.lua"
import "mod_assets/merethif_shields/scripts/objects.lua"
import "mod_assets/merethif_shields/scripts/materials.lua"
import "mod_assets/scripts/particles.lua"
import "mod_assets/chest/chest.lua"
import "mod_assets/scripts/animation_events.lua"
import "mod_assets/books/journal.lua"
import "mod_assets/books/spellbook.lua"
import "mod_assets/books/tome.lua"
import "mod_assets/scripts/grim_bed.lua"
import "mod_assets/scripts/levers.lua"
import "mod_assets/nightfall/scripts/items.lua"
import "mod_assets/nightfall/scripts/objects.lua"
import "mod_assets/nightfall/scripts/wall_sets.lua"
import "mod_assets/nightfall/scripts/recipes.lua"
import "mod_assets/nightfall/scripts/materials.lua"
import "mod_assets/nightfall/scripts/sounds.lua"
import "mod_assets/nightfall/scripts/spells.lua"
import "mod_assets/nightfall/scripts/particles.lua"
import "mod_assets/runebooks/runebooks.lua"
import "mod_assets/throwing_hammer/scripts/items.lua"
import "mod_assets/throwing_hammer/scripts/materials.lua"
import "mod_assets/dmcsb_pack/scripts/dmcsb_pack_init.lua"
import "mod_assets/dragon/dragon.lua"
import "mod_assets/plugins/slugomorg/slugomorg.lua"
import "mod_assets/scripts/crystals.lua"
import "mod_assets/plugins/beholder/beholder.lua"

--import exsp
import "mod_assets/exsp/exsp_init.lua"

As you can see, there is quite a bit, though most of these assets should not affect your framework in the slightest. I also have not altered the framework.lua in any way or included any modules other than the base modules. Here is also the framework.lua. Do I need to actually make some changes to it?

Code: Select all

--[[
LoG Scripting framework
Created by: JKos
Documentation: http://www.grimrock.net/forum/viewtopic.php?f=14&t=3321

INSTALLATION 

iclude this file to your init.lua after stadard_assets.lua

Like this:
[code]
-- import standard assets
import "assets/scripts/standard_assets.lua"

-- import custom assets
import "framework/framework.lua"
-- load desired framework modules
fw_loadModule('illusion_walls')

-- import custom assets
import "mod_assets/scripts/items.lua"
import "mod_assets/scripts/monsters.lua"
import "mod_assets/scripts/objects.lua"
import "mod_assets/scripts/wall_sets.lua"
import "mod_assets/scripts/recipes.lua"
import "mod_assets/scripts/materials.lua"
import "mod_assets/scripts/sounds.lua"

create script entity named logfw_init
and put this code to it:
----------------

spawn("LoGFramework", 1,1,1,0,'fwInit')
fwInit:open() -- this loads all script entites defined in framework.lua
-- timer will call this method automatically
-- 0.1 seconds after the game is started
-- you can also set debug-flag on here
function main()
timers:setLevels(1)
fw.debug.enabled = true
fwInit:close() --must be called
end

-----------------

DONE
]]

local showWarnings = true

local modules = {}
local loadOrder = {}
local moduleInitFunction = {}

-- Set to false if you dont wan't to see warnings about module scripts copy pasted to dungeon
function fw_setShowWarnings(show)
showWarnings = show
end

function fw_addModule(name,script)
modules[name] = script
loadOrder[#loadOrder+1] = name
end
function fw_addModuleInitCallback(modulename,callback)
moduleInitFunction[modulename] = callback
end

function fw_loadModule(name)
if modules[name] then return end
import('mod_assets/framework/modules/'..name..'.lua')
end

function tableToSet(list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
fw_loadModule('timers')
fw_loadModule('grimq')
fw_loadModule('fw')
fw_loadModule('data')
fw_loadModule('help')



cloneObject{
name = "LoGFramework",
baseObject = "dungeon_door_metal",
onOpen = function()
-- load modules

for moduleName,source in pairs(modules) do
local script = findEntity(moduleName)
if not script then
spawn("script_entity", party.level,1,1,0,moduleName)
script = findEntity(moduleName)
script:setSource(source)
else
if showWarnings then
print('script entity "'..moduleName..'" found from dungeon, the module from lua file was not loaded')
end
end
end
spawn('timer',party.level,0,0,0,'logfw_inittimer')
logfw_inittimer:addConnector('activate','logfw_init','main')
logfw_inittimer:setTimerInterval(0.1)
logfw_inittimer:activate()
end,
onClose = function()
for _,moduleName in ipairs(loadOrder) do
local moduleEntity = findEntity(moduleName)
if moduleInitFunction[moduleName] then
moduleInitFunction[moduleName](moduleEntity,grimq)
end

if moduleEntity and moduleEntity.activate then
moduleEntity.activate()
end
end
logfw_inittimer:deactivate()
logfw_inittimer:destroy()
fwInit:destroy()
end
}
[/code]

Any thoughts? It's not vital to my mod as most of the scripting has already been done, but it would be handy even for the new spells (which is the principle reason I downloaded it).
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 »

Well I suggest that you disable the exsp first and try if your dungeon works without it. If not, then it's probably a problem in my framework. You can try to debug it by creating a script entity named fw and copy pasting the script-entity part from the mod_assets/framework/modules/fw.lua to it. Script-entity part is the script which is passed as a argument to the fw_addModule-function. fw_addModule('fw',[[...]]) Those three dots represent the part which you should copy paste. This way the editor will show the line where the error is thrown, if it happens in fw-script entity.

Or if you are willing to share your dungeon with me you can send the sources to me (by private message) and I will try to debug it. If there is a problem in my framework I would like to fix it.
- 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
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: LoG Framework (dynamic hooks etc.)

Post by Grimfan »

As soon as I disabled exsp the game started running smoothly. So what could be the compatibility issue going on between the two mods? I thought they went together like ham and eggs? :?
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 »

Grimfan wrote:As soon as I disabled exsp the game started running smoothly. So what could be the compatibility issue going on between the two mods? I thought they went together like ham and eggs? :?
There may be a bug somewhere in my spells framework, or how it interacts with other elements you have. Anyway, it also needed optimization, but I don't have much time to work on it right now, unfortunately.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: LoG Framework (dynamic hooks etc.)

Post by Grimfan »

I've got it working in preview mode by importing the exsp scripts individually so no dramas. Because I'm not even up to half your level of competency at this it is probably my fault that it stuffed up anyhow.

Your spells are excellent by the way Diarmuid (particularly energy beam). I now just have to find places to put all the new spell scrolls into my relatively modestly sized dungeon. :)
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: LoG Framework (dynamic hooks etc.)

Post by Grimfan »

Diarmuid wrote:
Grimfan wrote:As soon as I disabled exsp the game started running smoothly. So what could be the compatibility issue going on between the two mods? I thought they went together like ham and eggs? :?
There may be a bug somewhere in my spells framework, or how it interacts with other elements you have. Anyway, it also needed optimization, but I don't have much time to work on it right now, unfortunately.
Within your spell framework did you fully resolve the grant exp function of spells, since not all the spells (especially Grimwold's) are granting exp when they destroy a target. For example, your flame carpet was granting exp for destroying my deep crowern, one of akroma's modified snails, and Wallasaurus's new leech monster but not for Wallasaurus's mummy grunt, which was rather odd (and I tried twice with the spell). Am I supposed to create a list of creatures to be affected by the spells within the dungeon or is this already supposed to be taken care of with your scripting (it seems at least partially it is)? Confusing... :?

I'm going to start playtesting my mod next week, so I will extensively test out your spells with my high-level party and give you the results down the track. ;)
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 »

Hmmm, it should if monsters are correctly imported withing the LoG framework.

Are you sure that the monsters are defined using fw_defineObject rather than defineObject, and that in init.lua, LoG framework is imported BEFORE the monsters, and EXSP is imported last?
Post Reply