Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CONFIGURAÇÕES --
- local doors= {14155, 14154, 14153, 14152}
- local door_table = {
- [action_id] = {x=1386, y=736, z=7},
- --etc
- }
- -- FIM CONFIGURAÇÕES --
- local function areThereCreaturesInArea(top_left, bottom_right)
- for x = top_left.x, bottom_right.x do
- for y = top_left.y, bottom_right.y do
- if isCreature(getTopCreature({x=x, y=y, z=top_left.z}).uid) then
- return true
- end
- end
- end
- return false
- end
- local function open(pos, i)
- if i < #doors then
- current = doors[i]
- next_ = doors[i+1]
- local door = getTileItemById(pos, current)
- if door.uid > 0 then
- doTransformItem(door.uid, next_)
- addEvent(open, 200, pos, i+1)
- end
- end
- end
- local function close_(pos, i)
- local top_left= {x = pos.x - 3, y = pos.y - 2, z = pos.z}
- local bottom_right= {x = pos.x, y = pos.y + 2, z = pos.z}
- if areThereCreaturesInArea(top_left, bottom_right) then
- return true
- end
- if i <= #doors and i > 1 then
- current = doors[i]
- next_ = doors[i-1]
- local door = getTileItemById(pos, current)
- if door.uid > 0 then
- doTransformItem(door.uid, next_)
- addEvent(close_, 200, pos, i-1)
- end
- end
- end
- function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
- local door_pos = door_table[item.actionid]
- if not door_pos then
- print("Error: door not configured. Action id: "..item.actionid)
- return true
- end
- for i = 1, #doors do
- local door = getTileItemById(door_pos, doors[i])
- if door.uid > 0 then
- open(door_pos, i)
- break
- end
- end
- return true
- end
- function onStepOut(cid, item, position, lastPosition, fromPosition, toPosition, actor)
- local door_pos = door_table[item.actionid]
- if not door_pos then
- print("Error: door not configured. Action id: "..item.actionid)
- return true
- end
- close_(door_pos, #doors)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement