Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2018, 10:45 PM
phate8908
Fire Beetle
 
Join Date: Dec 2018
Posts: 12
Default lua door:IsDoorOpen()

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
Reply With Quote
Reply

Tags
doors, lua, open


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:14 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3