i was looking for a way for my lua script to be able to see if a door is open or close... sadly couldn't find any way to do that besides making a timer but that seemed a bit hackish... so.. i made this little edit to the lua api to check if a door is open. Enjoy!
Code:
@@ -149,10 +149,15 @@ void Lua_Door::SetNoKeyring(int type) {
int Lua_Door::GetNoKeyring() {
Lua_Safe_Call_Int();
return self->GetNoKeyring();
}
+bool Lua_Door::IsDoorOpen() {
+ Lua_Safe_Call_Bool();
+ return self->IsDoorOpen();
+}
+
void Lua_Door::CreateDatabaseEntry() {
Lua_Safe_Call_Void();
self->CreateDatabaseEntry();
}
@@ -206,10 +211,11 @@ luabind::scope lua_register_door() {
.def("GetLockPick", (uint32(Lua_Door::*)(void))&Lua_Door::GetLockPick)
.def("SetKeyItem", (void(Lua_Door::*)(uint32))&Lua_Door::SetKeyItem)
.def("GetKeyItem", (uint32(Lua_Door::*)(void))&Lua_Door::GetKeyItem)
.def("SetNoKeyring", (void(Lua_Door::*)(int))&Lua_Door::SetNoKeyring)
.def("GetNoKeyring", (int(Lua_Door::*)(void))&Lua_Door::GetNoKeyring)
+ .def("IsDoorOpen", (bool(Lua_Door::*)(void))&Lua_Door::IsDoorOpen)
.def("CreateDatabaseEntry", (void(Lua_Door::*)(void))&Lua_Door::CreateDatabaseEntry)
.def("ForceOpen", (void(Lua_Door::*)(Lua_Mob))&Lua_Door::ForceOpen)
.def("ForceOpen", (void(Lua_Door::*)(Lua_Mob,bool))&Lua_Door::ForceOpen)
.def("ForceClose", (void(Lua_Door::*)(Lua_Mob))&Lua_Door::ForceClose)
.def("ForceClose", (void(Lua_Door::*)(Lua_Mob,bool))&Lua_Door::ForceClose);
Code:
@@ -55,10 +55,11 @@ public:
uint32 GetLockPick();
void SetKeyItem(uint32 key);
uint32 GetKeyItem();
void SetNoKeyring(int type);
int GetNoKeyring();
+ bool IsDoorOpen();
void CreateDatabaseEntry();
void ForceOpen(Lua_Mob sender);
void ForceOpen(Lua_Mob sender, bool alt_mode);
void ForceClose(Lua_Mob sender);
void ForceClose(Lua_Mob sender, bool alt_mode);
Example: acrylia\player.lua
Code:
function event_click_door(e)
local door_id = e.door:GetDoorID();
local entity_list = eq.get_entity_list()
if (door_id == 1 or door_id == 2 or door_id == 3 or door_id == 4) then
for doorid = 1,4 do
if (entity_list:FindDoor(door_id):IsDoorOpen()) then
if (door_id ~= doorid) then entity_list:FindDoor(doorid):ForceClose(e.self) end
else
if (door_id ~= doorid) then entity_list:FindDoor(doorid):ForceOpen(e.self) end
end
end
end
end