DM2 style sconces
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting. You may
to help finance the hosting costs of this forum.
Please read the Forum rules and policies before posting. You may

DM2 style sconces
Hi
Here is a rather hacky prototype for DM2 style lit sconces.
http://en.file-upload.net/download-8626 ... t.zip.html
Is there any way I could hook into party movement somehow rather than polling like crazy?
Of course, I don't really want to make system level changes in an importable arch, either...
edit: now with better message handling and more dramatic examples
Here is a rather hacky prototype for DM2 style lit sconces.
http://en.file-upload.net/download-8626 ... t.zip.html
Is there any way I could hook into party movement somehow rather than polling like crazy?
Of course, I don't really want to make system level changes in an importable arch, either...
edit: now with better message handling and more dramatic examples
Friends don't let friends eat worm round
-
- Novice
- Posts: 23
- Joined: Tue Dec 10, 2013 1:51 pm
Re: DM2 style sconces
Nice. Personally I like torches on the walls. If party is making light by spells and torches, it ends with maximum light everytime and everywhere. If only some places are lit, it is more atmospheric, in my opinion...
I am not sure what are you asking, but there is h_party_move hook, which is called everytime when party moves (as far as I know)Is there any way I could hook into party movement somehow rather than polling like crazy?
Re: DM2 style sconces
Thanks, that was exactly what I was asking 8-)
I suppose I should actually read through the base/ files instead of just grepping for a few likely strings...
http://en.file-upload.net/download-8634 ... t.zip.html
OK, this version responds to party movement instead of polling, and gives me a vaguely reasonable excuse to use that terrible, terrible singleton code 8-)
I suppose I should actually read through the base/ files instead of just grepping for a few likely strings...
http://en.file-upload.net/download-8634 ... t.zip.html
OK, this version responds to party movement instead of polling, and gives me a vaguely reasonable excuse to use that terrible, terrible singleton code 8-)
Friends don't let friends eat worm round
- Gambit37
- Should eat more pies
- Posts: 13768
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: DM2 style sconces
I've been looking at this code and I can't get it to work in DSB 0.69.
There are two errors. The first is with the definition of the archetype "sconce_light_manager". DSB complains that the arch is not a string, and it's because of the embedded function assigned to the "get_instance" method. I can fix that by simplifying the archetype definition and adding the function separately:
However, with that change I now get a second error with the rest of the code, because I think self is no longer referencing anything (I think)? DSB complains with:
I don't understand the self thing enough to know how to fix this. Any ideas?
There are two errors. The first is with the definition of the archetype "sconce_light_manager". DSB complains that the arch is not a string, and it's because of the embedded function assigned to the "get_instance" method. I can fix that by simplifying the archetype definition and adding the function separately:
Code: Select all
obj.sconce_light_manager = {
type="FLOORFLAT",
class="MECHANISM",
init_manager=light_manager_init,
do_update=light_manager_update,
add_flame=light_manager_add_flame,
remove_flame=light_manager_remove_flame
}
function obj.sconce_light_manager:get_instance(self)
-- check existing instance is real
if (self.instance ~= nil
and dsb_valid_inst(self.instance)
and dsb_find_arch(self.instance) == self) then
return self.instance
end
-- else try to find one
for id in dsb_insts() do
local arch = dsb_find_arch(id)
if (arch == self) then
self.instance = id
return id
end
end
-- else create one
self.instance = dsb_spawn(self,LIMBO,0,0,0)
self:init_manager(self.instance)
return self.instance
end
Code: Select all
FATAL LUA ERROR: Lua Function sys_party_move: dsb69\kaypy\sconcelight/sconce_flame.lua:187: attempt to index local 'self' (a nil value)
- Sophia
- Concise and Honest
- Posts: 4306
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: DM2 style sconces
There are actually two issues here. The first one is that if you're specifying a function definition with a colon instead of a dot, you don't need to actually have a self parameter, because Lua will automatically do so. So you can write
Actually you could also do
Anyway, the second problem is a change sometime in the last 4+ years. When kaypy's code was originally written, dsb_spawn accepted an archetype table entry as a parameter, but it currently does not, because I found out that led to some pretty obscure bugs if you messed this up. This is what DSB was originally complaining about. You can fix that by changing the "else create one" line to the following:
This will grab the arch's name as a string and will work properly.
Or at least crash with a clear error message.
Code: Select all
function obj.sconce_light_manager:get_instance()
Code: Select all
function obj.sconce_light_manager.get_instance(self)
Code: Select all
self.instance = dsb_spawn(self.ARCH_NAME, LIMBO, 0, 0, 0)
Or at least crash with a clear error message.

- Gambit37
- Should eat more pies
- Posts: 13768
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: DM2 style sconces
Thanks for this code. I can now play this test dungeon, but when I press the green button on level 2 which is set to activate the torches, DSB crashes again:
Since I'm not entirely sure what's going on here and I don't expect you to fix all this Sophia, I'll wait for Kaypy to update it 
Code: Select all
LUA ERROR: dsb69\kaypy\sconcelight/sconce_flame.lua:104: Archetypes must be specified as strings
FATAL LUA ERROR: Lua Function sconce_full.msg_handler[100002]: base/util.lua:188: table index is nil

Re: DM2 style sconces
If it hasn't fallen off the internet again, there should be an up-to-date version in with the probably solvable libraries
Friends don't let friends eat worm round
Re: DM2 style sconces
Lets see if this lasts a bit longer:
https://www.megaupload.us/4m4/sconcelight.zip
https://www.megaupload.us/4m4/sconcelight.zip
Friends don't let friends eat worm round
- Gambit37
- Should eat more pies
- Posts: 13768
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: DM2 style sconces
Wow, awesome, thank you. Yep, that version works fine (although I had to remove the relative path and put it all in the same folder as that didn't work for me).
I really like this lighting effect. Would it be OK to use it in one of my projects?
Oh, by the way, the Probably Solvable links are all dead too...
EDIT: I grabbed the scone file from your first link. You've since moved it to MegaUpload but that link doesn't work either.
I really like this lighting effect. Would it be OK to use it in one of my projects?
Oh, by the way, the Probably Solvable links are all dead too...

EDIT: I grabbed the scone file from your first link. You've since moved it to MegaUpload but that link doesn't work either.