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

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #23  
Old 02-26-2013, 11:31 AM
Harakiri23
Fire Beetle
 
Join Date: Jun 2009
Location: b
Posts: 11
Default

Quote:
Originally Posted by Zaela_S View Post
This thread has kind of died down and maybe there wasn't that much interest in the first place, but: I just re-read this and want to take a moment to make a case against using any auto-generated bindings/wrappers if a Lua quest scripting system does become a thing.
You want to simplify things but still dont want to use a wrapper ? I skimmed over your code - and the problem is - the same as with the perl system - only 1% will understand it and maintaining and extending will be done by copy&paste of existing code without really understanding it (e.g. people currently just paste code in the embperl classes for new functions - but thats not how its done, there should be a clean header file to perl exported functions and then the perlxs/convert is called which generates all the func bodies).

Whats worse - lua is stack based - thats a whole new level of understanding for most people. For perl, you were unable to expose complex objects (func args) to the quest system - now with direct lua calls you have the same issue - every complex object has to be manually coded - where in bindings its done in one line.

Look how WoW emus, EQ2, Ryzoom and other implemented their event system - and compare all the bad things and improve upon this - (BTW - they all use bindings). A quick example how a binding could look like for getters or setters

Code:
	  .def("GetName", &NPC::GetName)	  
	  .def("GetCleanName", &NPC::GetCleanName)	  
	  .def("GetID", &NPC::GetID)	  
	  .def("GetRace", &NPC::GetRace)	  
	  .def("GetClass", &NPC::GetClass)	  
          .def("Say", &NPC::Say)
Thats everything you need - number of args, arg types, etc all automatically handled - everybody understands this. No need for

Code:
static int Lua_GetName(lua_State* L) {
	int num_args = lua_gettop(L);
	if (!num_args || !lua_isuserdata(L,1))
		return 0;

	Mob* check = *(Mob**)lua_touserdata(L,1);
	if (check) {
		if (check->IsNPC()) {
			if (num_args > 1 && lua_isboolean(L,2) && lua_toboolean(L,2)) {
				lua_pushstring(L,check->GetName());
			}
			else {
				lua_pushstring(L,check->GetCleanName());
			}
		}
		else {
			lua_pushstring(L,check->GetName());
		}
		return 1;
	}
	return 0;
}
You still need at least one or two who understand lower level lua api - e.g. ever thought about garbage collection ? If you dont have the right approach here your embedded lua will be very slow and the memory will grow very quickly.

More things you need to take care of : script scoping - want to make sure that nobody can overwrite a var of another npc ? or do you want that ?

How can entities interact with each other directly?
Reply With Quote
 

Thread Tools
Display Modes

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 04:58 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3