NDOIA

From Legends of Aria Admin and Modding Wiki
Revision as of 15:58, 9 November 2019 by Gizmo (talk | contribs)
Jump to: navigation, search

ABCDEFGHIJKLMNOPQRSTUVWXYZ

Object Functions & Examples

AddModule(filename,table)

filename - Name of script file
table - Initializer table
The table may be omitted but allows you to send a table package to the script, then use the ModuleAttached Event to handle the table package.

Example script file named buff_player_strength.lua

 --buff players strength by 5 default
 --the buff duration will be 30 seconds.
 --if this script receives a initializer from an AddModule, set default values to the initializer values
 
 --setup default values
 defaultBuffAmount = 5
 defaultBuffTime = TimeSpan.FromSeconds(30)
 
 --- HandleModuleAttached - this is fired when this script gets attached to an object
 function HandleModuleAttached()
     -- if we received a initializer from the AddModule or template then update default values
     if (initializer ~= nil) then
         defaultBuffAmount = initializer.BuffAmount or 5
         defaultBuffTime = initializer.BuffTime or TimeSpan.FromSeconds(30)
     end
     -- make sure this object can receive the buff as it must be a mobile object
     if(this:IsMobile()) then
         SetMobileModExpire(this,"StrengthPlus","Unique_Buff_Handler",defaultBuffAmount,defaultBuffTime)    
     end
     -- remove this module script from the object now that we added the buff
     DelModule(GetCurrentModule())
 end
 
 --register the event handler for when this module gets attached to the current object
 RegisterEventHandler(EventType.ModuleAttached, GetCurrentModule(),HandleModuleAttached)

Example of adding the buff_player_strength module with an initializer

 Code Block
 Code Block
 Code Block