Page 1 of 1
How to...?
Posted: Tue Jun 29, 2010 10:47 pm
by Adamo
How to make a manacle, that swaps, say, cheese to corn?
It`s just an example, but I`m trying to understand how to build such swapper.
Re: How to...?
Posted: Wed Jun 30, 2010 12:26 am
by Sophia
Ok, first, make a "qswapper" (found in FloorFlats/MECHANICS) and Edit Swap Arch.
Choose corn as the thing to swap to, and set the swap target to "Operating Instance."
Then, make some manacles, and set them to by OpBy "cheese." Do not destroy the OpBy item, you need it to swap!
Set the target of the manacles to Activate the qswapper you just made.
When you click on the manacles with cheese, it'll swap the cheese to corn.
There are a couple examples of this in the test_dungeon, first in the "water purification" area and then where you put in the firestaff.
Re: How to...?
Posted: Wed Jun 30, 2010 8:38 am
by ian_scho
The test_dungeon is a great place to start, actually.... I mean READING it, not just loading it up in the editor!
Re: How to...?
Posted: Thu Jul 01, 2010 12:30 am
by Sophia
ian_scho wrote:The test_dungeon is a great place to start, actually.... I mean READING it, not just loading it up in the editor!
As of a few versions ago, the test_dungeon is made in ESB and is no longer hand-coded. That makes it a whole lot less nice to read.
Re: How to...?
Posted: Thu Jul 01, 2010 1:45 pm
by Adamo
thanx Sophia! ESB is still a kind of black magic to me!

Re: How to...?
Posted: Thu Jul 01, 2010 8:23 pm
by Adamo
ok, I checked out the "youcky water" case in the demo and I got the point. But what if I want to limit the activity of qswapper to X (say it`s four) swaps? I added another message sent from the manacles ("ACTIVATE") for a counter, wchich destroys the qswapper when neutralized. When a manacles is operated by cheese, it sends two ACT messages: one to qswapper and one to a counter, wchich - when neutrilized - destroys qswapper. It works all right, but after 4 swaps (4= counter value), I get Lua error message. It`s doesn`t crash the game, but there appears "LUA ERROR: CHECK LOG.TXT" message on top of the screen.
EDIT: ugh, what a dumb I am. The counter should have sent "cleanup" message to qswapper instead of destroying it...
EDIT2: ...but the deco is still active, and - despite qswapper doesn`t swap anything - it still works (= you get a specific click when touch by an operator)...

Re: How to...?
Posted: Fri Jul 02, 2010 3:09 am
by Sophia
My suggestion would be to put two duplicate manacles (or whatever wallitem trigger) on the wall, one which has no targets and is deactivated, and your triggering one that you have now. Set the counter to 4, and tell it send a Deactivate to your swapper-triggering wallitem and an Activate to the targetless wallitem. This means that the triggering one will disappear but the targetless one will appear at the same time, so there will appear to be no visual effect to the player. But this also means that clicking on it will no longer do anything, which (I think) is what you want.
Re: How to...?
Posted: Sat Jul 03, 2010 11:41 pm
by Adamo
Say the hook likes to eat corn. For every 3 corns it grants you one cheese in the alcove_short_bottom nearby. How to do that?
There are two problems:
- objects can be teleported, or moved, only to the regular alcoves. But objects like cheese cannot be moved to alcove_short_bottom and alcove_short_top (it doesn`t recieve anything, unless you will put it in the alcove directly by hand),
- I`m not sure how to make a MECHANICS/item_action to create object (newly created cheese moved to location xyz) each time it gets three messages; item_action mechanism ignores "count" exvar. I tried to put a counter (count = 3) between hook and item_action (hook sends ACT message to counter, when it gets 3 messages it sends ACT message to item_action, which creates an item), but it works only once this way (I don`t know how to force a counter to works instantly).
EDIT: Ok, I already figured how to do things. But the alcove problem is still unsolved.
Re: How to...?
Posted: Sun Jul 04, 2010 8:42 am
by Sophia
The good and bad news is that the alcove thing is a bug in DSB. There is no reason why "item_action" shouldn't be able to move something into the alcove, except that DSB currently has a logic error that keeps it from working right.
Here's a quick and dirty workaround.
Find the function
perform_item_action in
msg_handlers.lua (around line 940-something) and find the following line:
Code: Select all
operand = dsb_spawn(new_arch, lev, xc, yc, pos)
Replace it with:
Code: Select all
operand = dsb_spawn(new_arch, LIMBO, 0, 0, 0)
I'll come up with a better fix for the next DSB release.

Re: How to...?
Posted: Sun Jul 04, 2010 8:45 am
by Adamo
thanx!!!

When you have two short alcoves (_top and _bottom) in the same place, how would item_action know which target to pick? Or it takes a specified target randomly?
Re: How to...?
Posted: Sun Jul 04, 2010 8:51 am
by Sophia
It knows which to pick because it goes to the one that you target using the "item_action."
You don't set it to "Move to Location," but rather "Move Into Object," and target the short alcove with the item_action object.
This is necessary because, as you probably know, short alcoves need their objects to be INSIDE, not merely in the square like normal DM alcoves.
Re: How to...?
Posted: Sun Jul 04, 2010 5:39 pm
by Adamo
how can I add custom DECO objects into DSB? I decided not to modify any lua files in base folder, left everything as it was written by Sophia and make my eventual modifications in my own folder leaving the BASE unchanged. I made several customs (actually, a fountains, which I wanted to use as a decos), added their bitmaps into my folder, added several lines into objects.lua and created fountains.lua file. But it still doesn`t work - these decos can be used in ESB, but are not visible when you run a game.
adamo/objects.lua:
Code: Select all
dsb_import_arch("doublealcoves.lua", "alcove_short")
dsb_import_arch("fountains.lua", "fountain_lion_deco")
dsb_import_arch("fountains.lua", "fountain_lion_deco_dry")
dsb_import_arch("fountains.lua", "fountain_medusa_deco")
dsb_import_arch("fountains.lua", "fountain_medusa_deco_dry")
adamo/fountains.lua:
Code: Select all
obj.fountain_lion_deco = {
type="WALLITEM",
class="DECO",
front=gfx.fountain_lion_deco_front,
side=gfx.fountain_lion_deco_side,
on_click=wallitem_click
}
obj.fountain_lion_deco_dry = {
type="WALLITEM",
class="DECO",
front=gfx.fountain_lion_deco_dry_front,
side=gfx.fountain_lion_deco_dry_side,
on_click=wallitem_click
}
obj.fountain_medusa_deco = {
type="WALLITEM",
class="DECO",
front=gfx.fountain_medusa_deco_front,
side=gfx.fountain_medusa_deco_side,
on_click=wallitem_click
}
obj.fountain_medusa_deco_dry = {
type="WALLITEM",
class="DECO",
front=gfx.fountain_medusa_deco_dry_front,
side=gfx.fountain_medusa_deco_dry_side,
on_click=wallitem_click
}
the bitmaps these lines are referring to are:
- fountain_lion_deco_front.pcx,
- fountain_lion_deco_side.pcx,
- fountain_lion_deco_dry_front.pcx,
- fountain_lion_deco_dry_side.pcx,
- fountain_medusa_deco_front.pcx,
- fountain_medusa_deco_side.pcx,
- fountain_medusa_deco_dry_front.pcx,
- fountain_medusa_deco_dry_side.pcx
Re: How to...?
Posted: Sun Jul 04, 2010 6:28 pm
by ian_scho
The only thing that I can't see is at the start of fountains.lua
Code: Select all
-- Import images
gfx.fountain_lion_deco_front = dsb_get_bitmap("./wallsets/fountain_lion_deco_front")
...
The image path could be just "fountain_lion_deco_front" if it lives in the same directory, but I have mine in a subdirectory called 'wallsets'
Re: How to...?
Posted: Sun Jul 04, 2010 8:32 pm
by Sophia
If you're going to use importable archetypes (and I encourage you to do so!) you can make use of ROOT_NAME substitution to make your life a whole lot easier. Right now you're importing the same four archetypes four times, which isn't necessary.
As ian_scho pointed out, you need to load the graphics, as well.
Your code in
adamo/objects.lua is fine, I'd recommend something like the following in
adamo/fountains.lua:
Code: Select all
gfx[ROOT_NAME .. "_front"] = dsb_get_bitmap(ROOT_NAME .. "_front")
gfx[ROOT_NAME .. "_side"] = dsb_get_bitmap(ROOT_NAME .. "_side")
obj[ROOT_NAME] = {
type="WALLITEM",
class="DECO",
front=gfx[ROOT_NAME .. "_front"],
side=gfx[ROOT_NAME .. "_side"],
on_click=wallitem_click
}
Re: How to...?
Posted: Mon Jul 05, 2010 12:04 am
by Adamo
Here's a quick and dirty workaround.
Find the function perform_item_action in msg_handlers.lua (around line 940-something) and find the following line:
(...)
operand = dsb_spawn(new_arch, lev, xc, yc, pos)
Replace it with:
(...)
operand = dsb_spawn(new_arch, LIMBO, 0, 0, 0)
I'll come up with a better fix for the next DSB release.

that would be good, because current fix doesn`t work (nothing can be teleported into the short alcove) :/
Re: How to...?
Posted: Mon Jul 05, 2010 1:21 am
by Sophia
It worked for me! Are you sure you're doing it right?
You have to use an "item_action" to move it INTO the alcove, not just to the alcove's square.
Re: How to...?
Posted: Mon Jul 05, 2010 11:21 am
by Adamo
indeed it works! Sorry for that Sophia, it`s me who messed up..
Re: How to...?
Posted: Wed Nov 10, 2010 3:10 pm
by Joramun
Stupid question: how do I setup a victory condition with ESB ?
I perfectly know how to do it in a text editor, but there seems to be no "victory" object/condition/function set up defined in ESB !!
Re: How to...?
Posted: Wed Nov 10, 2010 7:06 pm
by Sophia
You're right, there isn't one.

Usually, the "victory condition" is so individual to the dungeon, I didn't think it was worth it to have a generic game ending triggerer.