ArcEmu: What Is The Luabridge Project? - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

What Is The Luabridge Project? Detailed explanation of the new lua interpreter.

#1 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 21 January 2011 - 10:09 PM

  • What is the new luabridge project?
    It is a new lua interpreter that uses the luabridge Lua to cpp binding framework by Nathan Reed to easily bind C++ classes and functions to the Lua environment.

  • Why use it over the current Lua engine?
    Current Lua Engine :
    • Has only one VM running.
    • The emulator has to use a mutex to synchronize code execution to prevent race issues such as stack corruption.
    • Scripts that execute alot of code can slow down other scripts(even slow down object updating across multiple maps) due to mutex use.(lock contention)
    • Global variables created are visible and open to manipulation by other scripts.
    • Coroutine use slows down performance.
    • Careless inheritance mechanism that give an object access to methods that aren't related to that object.(Player objects have access to creature methods.)
    • No object type casting required however.

    luabridge :
    • Has a VM created for every map instance created.
    • Scriptwriters can load only the scripts they need in each VM.(by using scripts to load other scripts)
    • Scripts running CPU extensive code will only slow down that specific map instance instead of all maps running Lua code.
    • Coroutines can be largely used without sacrificing performance.
    • Global variables declared in one VM are not visible to another VM(unless both VMs load the same script)
    • No synchronization is required(no mutex objects are used when executing Lua code.) which means faster scripts
    • Easy to bind new objects to Lua using the luabridge framework, easy maintenance, less code written and less bugs in the engine.
    • Lua syntax used to manipulate C++ objects is more similar its C++ counter part.
    • Elegant inheritance mechanism employed by luabridge.
    • Type casting is required however to access derived class methods when a base class object is pushed(alot of creature events push Units that maybe creatures or players.)
    • Directly binds core class objects meaning less documentation is needed.(Only if you can understand the C++ code.)

  • New objects in luabridge :

    • MapMgr

      Every Lua VM has access to it's MapMgr instance through a global 'MapMgr' variable.
      --In some script
      --Get the 'struct MapInfo' associated with current map.
      
      local mapinfo = MapMgr:GetMapInfo()
      
      --Now we can directly access those members using 'obj.member' syntax as shown below.
      
      print("Script running in map :" .. mapinfo.name .. " Map ID:" .. MapMgr:GetMapID() .. " Instance ID:" .. MapMgr:GetInstanceID() )
      
      --Spawning objects using mapmgrs interface.
      
      local mapface = MapMgr:GetInterface()
      local creature = mapface:SpawnCreature(crc_id, x, y, z, o, true, false, 0, 0, 1);
      local go = mapface:SpawnGameObject(go_id, x, y, z, o, true, 0, 0, 1)
      
      --Notice how the GetObjectNearestCoords methods changed from obj:GetObjectNearestCoords to MapMgr:GetInterface():GetObjectNearestCoords()
      
      creature = mapface:GetCreatureNearestCoords(x,y,z crc_id)
      go = mapface:GetGameObjectNearestCoords(x,y,z, go_id)
      local random_player = mapface:GetPlayerNearestCoords(x,y,z,0)
      random_player = MapMgr:GetPlayer("playername")
      


    • TaxiMgr, Taxi Path and Taxi Nodes

      Every VM has access to sTaxiMgr singleton object through a global 'sTaxiMgr' variable.
      //Get a taxi node near some coords
      
      local node = sTaxiMgr:GetTaxiNode( sTaxiMgr:GetNearestTaxiNode(x,y,z, MapMgr:GetMapID() ) )
      
      //Now we can access the members of that taxi node.
      
      print("Taxi Node ID:" .. node.id .. " x :" .. node.x .."y :" .. node.y .. "z:" .. node.z .. " map:" .. node.mapid )
      
      //We can also modify those members by simply assigning them to something new.
      
      node.x = newx
      node.y = newy
      node.z = newz
      
      //Taxi paths
      
      local path = sTaxiMgr:GetTaxiPath( pathid)
      

    • Object based databases, QueryResults and Fields.

      The world and character are now objects accessed via global variables 'WorldDB' and 'CharacterDB' respectively.
      //Execute some statements on the databases
      
      WorldDB:Execute( "some query" )
      CharacterDB:Execute( "another query" )
      
      //Now let's query for information
      
      local result = CharacterDB:Query( "some query" )
      print("Query Columns :" .. result:GetFieldCount() .. "Row Count:" .. result:GetRowCount() )
      
      //access a stored string in column 1.
      
      local stored_string = result:GetColumn(1):GetStr()
      


1

#2 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 21 January 2011 - 10:25 PM

Looks good :P
"The demand for free goods is infinite."
0

#3 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 21 January 2011 - 10:49 PM

mani thx.
Still incomplete, I'll try to list what functions changed.
0

#4 User is offline   Marforius 

  • Permanantly on leave
  • PipPipPipPip
  • Group: Members
  • Posts: 597
  • Joined: 07-August 08
  • IRC:Marforius
  • Gender:Male
  • Location:Rome
  • Interests:ArcEmulatorius
  • Server OS:Linux

Posted 22 January 2011 - 12:47 AM

Looks good, I cant wait to use it.
0

#5 User is offline   WAmadeus 

  • Cunning Code Composer
  • PipPipPip
  • Group: Developers
  • Posts: 287
  • Joined: 23-July 09
  • Gender:Male
  • Location:Brazil

Posted 22 January 2011 - 11:00 AM

Nice one, Parox!
0

#6 User is offline   Navid 

  • Persian Prance of ArcEmu
  • Group: Super Moderator
  • Posts: 718
  • Joined: 30-June 09
  • IRC:Lurker-
  • Gender:Male
  • Location:Iran
  • Interests:PHP,C++,ArcEmu and exactly our lovely community and specially money xD
  • Server OS:Windows

Posted 22 January 2011 - 07:34 PM

Good work Paroxy
I'm here to check,lurk and kill you so behave or you will be lurked

Posted Image
0

#7 User is offline   Datastream1 

  • Member
  • Pip
  • Group: Members
  • Posts: 87
  • Joined: 15-April 09
  • Gender:Male
  • Location:the great US&A
  • Server OS:Other

Posted 22 January 2011 - 07:54 PM

Good work! looks good for all those LuaFanBoiz :)
Posted Image
need halp with a C++ script? message me! :P
0

#8 User is offline   Marforius 

  • Permanantly on leave
  • PipPipPipPip
  • Group: Members
  • Posts: 597
  • Joined: 07-August 08
  • IRC:Marforius
  • Gender:Male
  • Location:Rome
  • Interests:ArcEmulatorius
  • Server OS:Linux

Posted 23 January 2011 - 04:27 AM

View PostDatastream1, on 22 January 2011 - 07:54 PM, said:

Good work! looks good for all those LuaFanBoiz :)


if name = Datastream then
print("Closet LuaFanBoy found");
end

1

#9 User is offline   Neglected 

  • Member
  • Pip
  • Group: Members
  • Posts: 25
  • Joined: 27-May 09
  • Gender:Male

Posted 18 February 2011 - 12:30 PM

View PostMarforius, on 23 January 2011 - 04:27 AM, said:

if name = Datastream then
print("Closet LuaFanBoy found");
end


*cough*.
expected = near `=` on line 1.
Lua Wiki Editor.
Ahn'Qiraj PvP EU - Hitswitch [Rogue]; Aeire [Priest]; Neglected [Warlock]
0

#10 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 19 February 2011 - 01:46 AM

I read on wow-v someone was having an issue was 'MapMgr' being nil. The reason this occurs is because that variable is initialized to the MapMgr that belongs to that lua instance. However, there is a default lua instance that functions as a compiler which is created independantly of any MapMgr. It functions to alert the writer of any syntax errors it encounters when scripts are initially loaded at server startup and consequently after the engine is restarted. This instance always loads all .lua files and reports any errors. It however, never actually runs the script code since all scripted objects run under some MapMgr.

So, when you bump into a nil MapMgr variable, you know that it's the compiler instance that attempted to load that script. You can ignore this error, or you can write robust code to ignore executing further statements that depend on a valid MapMgr instance. E.g
if MapMgr ~= nil then .... end

0

#11 User is offline   Marforius 

  • Permanantly on leave
  • PipPipPipPip
  • Group: Members
  • Posts: 597
  • Joined: 07-August 08
  • IRC:Marforius
  • Gender:Male
  • Location:Rome
  • Interests:ArcEmulatorius
  • Server OS:Linux

Posted 19 February 2011 - 06:41 AM

View PostNeglected, on 18 February 2011 - 12:30 PM, said:

*cough*.
expected = near `=` on line 1.


expected `you` near `trolling-with-me` on line 2.
1

#12 User is offline   sleinzelmann 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 24-September 10
  • Gender:Male

Posted 14 March 2011 - 01:50 PM

Thanks for that Introduction

So I just got 2 Questions :)

How To Check if the player is in combat...

And Would you make a Tutorial, because im lost without some Advice :)

My Server ist still working with the old LuaEngine, but the VM-Thing sounds interesting, so i would be very proud about more information :)

Greetings :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users