Scripting Additions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Wholley
Posts: 19
Joined: Thu Apr 12, 2012 1:57 pm

Scripting Additions

Post 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.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Scripting Additions

Post by petri »

Removing/destroying items is currently not supported by the scripting interface but it's on my todo list.
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting Additions

Post 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
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Scripting Additions

Post 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.
Friction
Posts: 3
Joined: Sun Aug 26, 2012 6:45 pm

Re: Scripting Additions

Post 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:
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting Additions

Post 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
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Scripting Additions

Post 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.
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting Additions

Post 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
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Scripting Additions

Post 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 :)
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting Additions

Post 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!
Finished Dungeons - complete mods to play
Post Reply