Caduceus
Unknown Member
- Joined
- May 10, 2010
- Messages
- 321
- Solutions
- 2
- Reaction score
- 24
I am having difficulty figuring out how to add a check. if the wall "9119" is missing, then cannot use item again within the 5 second timer. This issue is when the item 2080, piano, is used after the wall is removed. It then moves to the next item in the stack pos 3. Which is an archway. The script as a whole works, aside from this one flaw.
I know I can obviously do this:
Code:
-- If door is open, then can not reuse again while open.
if blah then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Door is already active.")
return false
end
Code:
local storage = 15001
local wallPos = {
[1] = {x=1024, y=929, z=9, stackpos=3}
}
local time_ = 5 -- 5 seconds
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local function reset()
-- reset walls
Game.createItem(9119, 1, wallPos[1])
end
-- check if player has storage
if player:getStorageValue(storage) < 1 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You must complete Catacombs Quest!")
doSendMagicEffect(pos, CONST_ME_POOF)
return false
else
-- If door is open, then can not reuse again while open.
if blah then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Door is already active.")
return false
end
end
-- add reset
addEvent(reset, time_ * 1000)
-- remove walls, send message
for i = 1, #wallPos do
item:getPosition():sendMagicEffect(CONST_ME_SOUND_BLUE)
doRemoveItem(getThingfromPos(wallPos[i]).uid)
end
player:sendTextMessage(MESSAGE_INFO_DESCR, "Hurry, the wall is closing!")
return true
end
I know I can obviously do this:
Code:
local storage = 15001
local wallPos = {
[1] = {x=1024, y=929, z=9, stackpos=3}
}
local time_ = 5 -- 5 seconds
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local function reset()
-- reset switch
item:transform(2080)
-- reset walls
Game.createItem(9119, 1, wallPos[1])
end
-- check if lever is currently used
if player:getStorageValue(storage) < 1 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You must complete Catacombs Quest!")
doSendMagicEffect(pos, CONST_ME_POOF)
return false
end
-- If door is open, then can not reuse again while open.
if item.itemid == 2082 then
player:sendTextMessage(MESSAGE_INFO_DESCR, "Door is already active.")
return false
end
-- add reset
item:transform(2082)
addEvent(reset, time_ * 1000)
-- remove walls, send message
for i = 1, #wallPos do
item:getPosition():sendMagicEffect(CONST_ME_SOUND_BLUE)
doRemoveItem(getThingfromPos(wallPos[i]).uid)
end
player:sendTextMessage(MESSAGE_INFO_DESCR, "Hurry, the wall is closing!")
return true
end
Last edited: