(fixed) Floor Triggers don't call 'func' exvar...

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
Remy
Craftsman
Posts: 111
Joined: Wed Sep 05, 2007 5:24 pm
Contact:

(fixed) Floor Triggers don't call 'func' exvar...

Post by Remy »

I was experimenting with the 'func' exvar and noticed a peculiar thing - floor triggers don't "trigger" the function call. I tracked it down to the floor_trigger and floor_trigger_off handlers (base\triggers.lua:176, :214), and what happens is they bail out before calling on_trigger if 'exvar[id].target' doesn't exist. I understand why, but I'm wondering if it should check for the existance of 'func' as well. I imagine that a few people are going to use floor triggers to call the end of the game, and not all those floor triggers will specify targets.

Edit**
And a quick check showed that while wallitem_click will trigger, it doesn't play a sound. So now I'm beginning to wonder if there's a reason to use the function_caller archtype over the 'func' exvar.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Good observations. I've fixed the func thing.

In looking into this, I also noticed the sound playing behavior is fairly inconsistent and weird between floor triggers and wallitems in general. So, here is my proposed algorithm for sound playing:
  1. If exvar[id].silent is true, return.
  2. If exvar[id].sound is defined, play it and return.
  3. If arch.default_silent is true, return.
  4. If arch.default_sound is defined, play it and return.
  5. If arch.class is "KEYHOLE", "BUTTON", or "TRIGGER", play a click and return.
  6. Play no sound and return.
Thoughts?

Oh, and about func_caller-- its main use is that it calls functions in response to messages instead of clicks. That might be handy for some applications where you have custom code but you don't need to build a whole custom archetype to get it into the dungeon. It's sort of like a Lua-ized version of an RTC WALLITEM_ACTION.
Last edited by Sophia on Mon Nov 05, 2007 7:08 pm, edited 1 time in total.
User avatar
Joramun
Mon Master
Posts: 925
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

It sounds fair :wink:

But I would put 2. before 1., because it is easier to toggle an item from silent to noisy, than to regenerate the value of the "sound" exvar.
So an item with sound="blob", and silent="true" would be silent.
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

True. I edited the list.

By the way, I don't want to be overly pedantic, but silent="true" (that is, setting it to the string "true" not the boolean value true) will work, but only because Lua understands anything other than nil or false as a true. If you try to set silent="false" it will not do what you expect. :)
Post Reply