Page 1 of 1

Scripting Additions

Posted: Wed Sep 12, 2012 7:17 pm
by Wholley
I am already hard at work breaking your scripting stuff and trying various things out with them. I have a question though...We are able to addItems to various spots in the dungeons...alcoves, altars, and such but I find no way to, at least script wise remove items. Reason for this is the following...I show the party all these wonderful magical goodies only to have them vanish before their eye before they can remove/pickup said items. I have tried variation of removeItem and such but no luck. Is there not a command to remove/destroy items? Thanks in advance. Will be uploading my bug reports a little later.

Re: Scripting Additions

Posted: Wed Sep 12, 2012 7:56 pm
by petri
Removing/destroying items is currently not supported by the scripting interface but it's on my todo list.

Re: Scripting Additions

Posted: Wed Sep 12, 2012 7:59 pm
by Komag
Is there some equivalent to getLeverState for pressure plates, such as getPlateState?

Right now I've rigged a setup where two pressure plates need to be weighted down to open a door:
- each pressure plate activates a script that toggles a lever (in a faraway blue room)
- then I have the combination lock script set up with the levers, so when they are both activated, the door opens

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:01 pm
by petri
Komag wrote:Is there some equivalent to getLeverState for pressure plates, such as getPlateState?
It seems to be missing. I'll add it in the next update. Thanks for letting us know!

It's easy to script a workaround though: just increment/decrement a counter when the pad is activated/deactivated and check the counter's value when needed.

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:04 pm
by Friction
I am already hard at work breaking your scripting stuff and trying various things out with them. I have a question though...We are able to addItems to various spots in the dungeons...alcoves, altars, and such but I find no way to, at least script wise remove items. Reason for this is the following...I show the party all these wonderful magical goodies only to have them vanish before their eye before they can remove/pickup said items. I have tried variation of removeItem and such but no luck. Is there not a command to remove/destroy items? Thanks in advance. Will be uploading my bug reports a little later.
Would a terrible kludge work where the party onPickUpItem hook sets the item-to-be-picked's type to something else? :lol:

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:23 pm
by Komag
petri wrote: It's easy to script a workaround though: just increment/decrement a counter when the pad is activated/deactivated and check the counter's value when needed.
Hmm, I tested this by linking three plates to a counter set to 3 (with proper activate -> decrememt, and deactivate -> increment)
It works and the door opens (yay!), but then removing a weight from one of the plates doesn't close the door again. The counter only sends a signal on zero, so if the door link is set to toggle, then removing a weight and adding it again will close the door, but that's not what I want

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:26 pm
by petri
Komag wrote:Is there some equivalent to getLeverState for pressure plates, such as getPlateState?

Right now I've rigged a setup where two pressure plates need to be weighted down to open a door:
- each pressure plate activates a script that toggles a lever (in a faraway blue room)
- then I have the combination lock script set up with the levers, so when they are both activated, the door opens
If you just want to setup a puzzle that opens a door when two pads are pressed, the easiest way is to add a single counter that starts from 2. Each pad when activated decrements the counter by 1, and when deactivated increments the counter by 1. When the counter reaches 0 it then triggers and opens the door. No scripts needed.

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:29 pm
by Komag
yes, thank you, that's what currently works, but I also want the door to close again if one of the weights is taken off

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:33 pm
by petri
Komag wrote:yes, thank you, that's what currently works, but I also want the door to close again if one of the weights is taken off
You can replace the counter with a script entity to get more control, for example:

Code: Select all

counter = 2

function activate()
  counter = counter - 1
  checkValue()
end

function deactivate()
  counter = counter + 1
  checkValue()
end

function checkValue()
  if counter == 0 then
    door:open()
  else
    door:close()
  end
end
Hope this helps!

EDIT: oops fixed a couple of bugs :)

Re: Scripting Additions

Posted: Wed Sep 12, 2012 8:44 pm
by Komag
It worked (after I switched the + and the - and added an end), thanks a lot!

EDIT - you beat me to it and fixed the code already!