Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,334
- Solutions
- 68
- Reaction score
- 1,012
This code can replace your doors.lua
Why use this? You can set up the doors aid to check for quest, vocation, and level.
In the original door.lua code, quest doors would be accessible as long as the players storage (defined by the doors aid) is not nil then they can enter the door. With this code you can define certain times that the player can enter during the quest.
NOTE: Only actual quest doors can be used for a quest door.
There is no need to edit your actions.xml Just replace this code and set up your tables in the code for your needs. Enjoy =)
Why use this? You can set up the doors aid to check for quest, vocation, and level.
In the original door.lua code, quest doors would be accessible as long as the players storage (defined by the doors aid) is not nil then they can enter the door. With this code you can define certain times that the player can enter during the quest.
NOTE: Only actual quest doors can be used for a quest door.
There is no need to edit your actions.xml Just replace this code and set up your tables in the code for your needs. Enjoy =)
Lua:
local questDoors = {
[1000] = {questValues = {5, 6}}
}
local vocationDoors = {
[1000] = {vocs = {1, 2, 3, 4}}
}
local levelDoors = {
[1000] = {levelMin = 50, levelMax = nil}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemId = item:getId()
local voc = vocationDoors(itemAid)
local level = levelDoors(itemAid)
-- VOCATION DOORS --
if voc and not isInArray(voc.vocs, player:getVocation():getId()) then
local text = "Only "
for i = 1, #voc.vocs do
local VOC = Vocation(voc.vocs[i])
if VOC then
text = text..""..VOC:getName()..", "
end
end
text = text.." can enter here."
return player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
-- LEVEL DOORS --
if level then
if level.levelMax ~= nil then
return player:sendTextMessage(MESSAGE_INFO_DESCR, "Only levels "..level.levelMin.." - "..level.levelMax.." can enter here.")
else
return player:sendTextMessage(MESSAGE_INFO_DESCR, "Only levels "..level.levelMin.." and higher can enter here.")
end
end
-- QUEST DOORS --
if isInArray(questDoors, itemId) then
local quest = questDoors[item:getActionId()]
if not quest then return player:sendTextMessage(MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.") end
if player:getStorageValue(item:getActionId()) ~= nil and isInArray(quest.questValues, player:getStorageValue(item:getActionId())) then
item:transform(itemId + 1)
player:teleportTo(toPosition, true)
else
return player:sendTextMessage(MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
end
end
if isInArray(keys, itemId) then
if target.actionid > 0 then
if item.actionid == target.actionid and doors[target.itemid] then
target:transform(doors[target.itemid])
return true
end
player:sendTextMessage(MESSAGE_STATUS_SMALL, "The key does not match.")
return true
end
return false
end
if isInArray(horizontalOpenDoors, itemId) or isInArray(verticalOpenDoors, itemId) then
local doorCreature = Tile(toPosition):getTopCreature()
if doorCreature ~= nil then
toPosition.x = toPosition.x + 1
local query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
if query ~= RETURNVALUE_NOERROR then
toPosition.x = toPosition.x - 1
toPosition.y = toPosition.y + 1
query = Tile(toPosition):queryAdd(doorCreature, bit.bor(FLAG_IGNOREBLOCKCREATURE, FLAG_PATHFINDING))
end
if query ~= RETURNVALUE_NOERROR then
player:sendTextMessage(MESSAGE_STATUS_SMALL, query)
return true
end
doorCreature:teleportTo(toPosition, true)
end
if not isInArray(openSpecialDoors, itemId) then
item:transform(itemId - 1)
end
return true
end
if doors[itemId] then
if item.actionid == 0 then
item:transform(doors[itemId])
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "It is locked.")
end
return true
end
return false
end