My newest little bit of scripting
Posted: Fri Jan 25, 2013 9:42 am
You guys are probably bored of my little entry level scripts, but I'm having a blast trying to figure this stuff out.
Here is my latest script.
Basically I need to have an available supply of bombs until the pit is closed. So the script checks if the pit is closed, then checks both alcoves and if they are empty puts a bomb in them.
Sometimes I think it's harder to design puzzles than to solve them.
What I've got going on is the basic throw an item across a pit to activate a pressure plate and close the pit. But I wanted to make it so the plate is activated by bombs only. So I came up with the idea to require the plate to be activated multiple times because a bomb will activate the plate then self destruct. Connected to a counter to count down and eventually close the pit. Great, but what if someone throws a rock first, then the plate will never deactivate and trap the player forever. So I put a teleport on the plate with a small delay and it would teleport the rock back to the player. However the counter still got triggered, so the pit would close even though no bombs were thrown. So I then used the timer to increment the counter to offset when the rocks activated the plate, but that didn't work either because it also reset when bombs were thrown. Then I put the teleporter connected to a wall button so the teleporter only comes on if the player pushes it, like a reset button.
Now that I got that part functioning I needed to make sure the player has bombs available. Thats where my script comes in. I have two alcoves to make bombs available, as long as they are empty. so the player will be able to complete the puzzle. Great my puzzle is complete, but wait another issue has arrived, the player now has an endless supply of bombs. However I didn't want the player to have an endless supply of bombs so I went back and added the pit close check to stop the supply once the pit closed.
Yeah I'm done, but not quite. Theres nothing stopping the player from loading up on bombs before solving the puzzle. I can think of two ways to deal with this so far, one is to search the players inventories, count how many shock bombs they have before reaching the puzzle and after the puzzle somehow removing the excess, or making sure no shock bombs are available up til this point and removing all shock bombs afterwards, or leaving a couple. I don't know, but I probably won't have a chance to look at it until this weekend.
Here is my latest script.
Code: Select all
--add bomb to alcove--
function addBomb()
local pitcheck = true
if pitcheck == BombCheckPit:isOpen() then
local bombcheck = BombAlcove1:getItemCount()
local bombcheck2 = BombAlcove2:getItemCount()
if bombcheck == 0 then
BombAlcove1:addItem(spawn("shock_bomb"))
if bombcheck2 == 0 then
BombAlcove2:addItem(spawn("shock_bomb"))
end
else
if bombcheck2 == 0 then
BombAlcove2:addItem(spawn("shock_bomb"))
end
end
end
end
Sometimes I think it's harder to design puzzles than to solve them.
What I've got going on is the basic throw an item across a pit to activate a pressure plate and close the pit. But I wanted to make it so the plate is activated by bombs only. So I came up with the idea to require the plate to be activated multiple times because a bomb will activate the plate then self destruct. Connected to a counter to count down and eventually close the pit. Great, but what if someone throws a rock first, then the plate will never deactivate and trap the player forever. So I put a teleport on the plate with a small delay and it would teleport the rock back to the player. However the counter still got triggered, so the pit would close even though no bombs were thrown. So I then used the timer to increment the counter to offset when the rocks activated the plate, but that didn't work either because it also reset when bombs were thrown. Then I put the teleporter connected to a wall button so the teleporter only comes on if the player pushes it, like a reset button.
Now that I got that part functioning I needed to make sure the player has bombs available. Thats where my script comes in. I have two alcoves to make bombs available, as long as they are empty. so the player will be able to complete the puzzle. Great my puzzle is complete, but wait another issue has arrived, the player now has an endless supply of bombs. However I didn't want the player to have an endless supply of bombs so I went back and added the pit close check to stop the supply once the pit closed.
Yeah I'm done, but not quite. Theres nothing stopping the player from loading up on bombs before solving the puzzle. I can think of two ways to deal with this so far, one is to search the players inventories, count how many shock bombs they have before reaching the puzzle and after the puzzle somehow removing the excess, or making sure no shock bombs are available up til this point and removing all shock bombs afterwards, or leaving a couple. I don't know, but I probably won't have a chance to look at it until this weekend.