NDOIA
Object Functions & Examples
AddModule(filename,table) filename - Name of script filetable - 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) function HandleModuleAttached() if (initializer ~= nil) then defaultBuffAmount = initializer.BuffAmount or 5 defaultBuffTime = initializer.BuffTime or TimeSpan.FromSeconds(30) end if(this:IsMobile()) then SetMobileModExpire(this,"StrengthPlus","Unique_Buff_Handler",defaultBuffAmount,defaultBuffTime) end end --register the event handler for when this module gets attached to the current object RegisterEventHandler(EventType.ModuleAttached, GetCurrentModule(),HandleModuleAttached)
Example of adding a module with a initializer table
Code Block Code Block Code Block
Example of Handling the initializer table on an object
Code Block Code Block Code Block