Skip to content
Draft
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
70 changes: 70 additions & 0 deletions data/lib/004register/action.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local ActionRegister = false
do
local mt = getmetatable(Action)
local defaultCall = mt.__call

mt.__call = function(self, params)
-- we need to make sure that the Action contains a setup table, if not we are using an outdated version
if not params then
print(("You are using scripts with an outdated version of revscriptsys (Action)"))
print(string.format(">> file: %s\n", debug.getinfo(2, "S").source))
return defaultCall(self)
end
-- we are adding the table params with the parameters onto self without calling __newindex
ActionRegister = params
return defaultCall(self)
end
end

-- hooking the callback function to c
-- if not we are just adding it as a regular table index without calling __newindex
do
local function ActionNewIndex(self, key, value)
-- we need to make sure that we are pushing something as a callback function
if type(value) == "function" then
-- we know now that it is a function and hook it in c
self:onUse(key, value)

-- checking for outdated revscriptsys
if not ActionRegister then
-- using outdated version, we just gracefully return
return
end
-- now that we know that we have a hooked event we want to pass the params and register

-- some prior checks to see if there is any type of id set
local ids = {"id", "aid", "uid"}
local found = false
for i = 1, #ids do
if ActionRegister[ids[i]] then
found = true
break
end
end

-- making aware that there is no ids set if that's the case
if not found then
print("There is no id/aid/uid set for this callback: ".. key)
return
end

-- we are safe to go now as we are sure that everything is correct
for func, params in pairs(ActionRegister) do
if type(params) == "table" then
self[func](self, unpack(params))
else
self[func](self, params)
end
end

-- now we are registering, which frees our userdata
self:register()
-- resetting the global variable which holds our parameter table
ActionRegister = false

return
end
rawset(self, key, value)
end
rawgetmetatable("Action").__newindex = ActionNewIndex
end
77 changes: 77 additions & 0 deletions data/lib/004register/creatureevent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
local CreatureEventRegister = false
local eventList = {["onLogin"] = "login", ["onLogout"] = "logout", ["onThink"] = "think", ["onPrepareDeath"] = "preparedeath", ["onDeath"] = "death", ["onKill"] = "kill", ["onAdvance"] = "advance", ["onModalWindow"] = "modalwindow", ["onTextEdit"] = "textedit", ["onHealthChange"] = "healthchange", ["onManaChange"] = "manachange", ["onExtendedOpcode"] = "extendedopcode"}
do
local mt = getmetatable(CreatureEvent)
local defaultCall = mt.__call

mt.__call = function(self, params)
-- we need to make sure that the CreatureEvent contains a setup table, if not we are using an outdated version
if type(params) == "string" then
print("You are using scripts with an outdated version of revscriptsys (CreatureEvent)")
print(string.format(">> file: %s\n", debug.getinfo(2, "S").source))
return defaultCall(self, params)
end
-- we are adding the table params with the parameters onto self without calling __newindex
CreatureEventRegister = params
return defaultCall(self)
end
end

-- hooking the callback function to c
-- if not we are just adding it as a regular table index without calling __newindex
do
local function CreatureEventNewIndex(self, key, value)
-- we need to make sure that we are pushing something as a callback function
if type(value) == "function" then
-- we know now that it is a function and hook it in c
-- checking for outdated revscriptsys
if CreatureEventRegister then
-- looking if event has been set so we can directly hook
if CreatureEventRegister.event then
-- eventType is set through our config table
self:event(CreatureEventRegister.event)
self[CreatureEventRegister.event](self, key, value)
else
-- we get the type through the hook name
for k, v in pairs(eventList) do
if key:lower():find(k:lower()) then
-- found the right event and hook it
self:event(v)
self[k](self, key, value)
end
end
end
else
self:event(eventList[key])
self[key](self, key, value)
-- using outdated version, we just gracefully return
return
end
-- now that we know that we have a hooked event we want to pass the params and register

-- making aware that there is no event name set if that's the case
if not CreatureEventRegister.name then
print("There is no event name set for this callback: ".. key)
return
end

-- we are safe to go now as we are sure that everything is correct
for func, params in pairs(CreatureEventRegister) do
if type(params) == "table" then
self[func](self, unpack(params))
else
self[func](self, params)
end
end

-- now we are registering, which frees our userdata
self:register()
-- resetting the global variable which holds our parameter table
CreatureEventRegister = false

return
end
rawset(self, key, value)
end
rawgetmetatable("CreatureEvent").__newindex = CreatureEventNewIndex
end
77 changes: 77 additions & 0 deletions data/lib/004register/globalevent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
local GlobalEventRegister = false
local eventList = {["onThink"] = "think", ["onTime"] = "time", ["onStartup"] = "startup", ["onShutdown"] = "shutdown", ["onRecord"] = "record"}
do
local mt = getmetatable(GlobalEvent)
local defaultCall = mt.__call

mt.__call = function(self, params)
-- we need to make sure that the GlobalEvent contains a setup table, if not we are using an outdated version
if type(params) == "string" then
print("You are using scripts with an outdated version of revscriptsys (GlobalEvent)")
print(string.format(">> file: %s\n", debug.getinfo(2, "S").source))
return defaultCall(self, params)
end
-- we are adding the table params with the parameters onto self without calling __newindex
GlobalEventRegister = params
return defaultCall(self)
end
end

-- hooking the callback function to c
-- if not we are just adding it as a regular table index without calling __newindex
do
local function GlobalEventNewIndex(self, key, value)
-- we need to make sure that we are pushing something as a callback function
if type(value) == "function" then
-- we know now that it is a function and hook it in c
-- checking for outdated revscriptsys
if GlobalEventRegister then
-- looking if event has been set so we can directly hook
if GlobalEventRegister.event then
-- eventType is set through our config table
self:event(GlobalEventRegister.event)
self[GlobalEventRegister.event](self, key, value)
else
-- we get the type through the hook name
for k, v in pairs(eventList) do
if key:lower():find(k:lower()) then
-- found the right event and hook it
self:event(v)
self[k](self, key, value)
end
end
end
else
self:event(eventList[key])
self[key](self, key, value)
-- using outdated version, we just gracefully return
return
end
-- now that we know that we have a hooked event we want to pass the params and register

-- making aware that there is no event name set if that's the case
if not GlobalEventRegister.name then
print("There is no event name set for this callback: ".. key)
return
end

-- we are safe to go now as we are sure that everything is correct
for func, params in pairs(GlobalEventRegister) do
if type(params) == "table" then
self[func](self, unpack(params))
else
self[func](self, params)
end
end

-- now we are registering, which frees our userdata
self:register()
-- resetting the global variable which holds our parameter table
GlobalEventRegister = false

return
end
rawset(self, key, value)
end
rawgetmetatable("GlobalEvent").__newindex = GlobalEventNewIndex
end
88 changes: 88 additions & 0 deletions data/lib/004register/moveevent.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
local MoveEventRegister = false
local eventList = {["onStepIn"] = "stepin", ["onStepOut"] = "stepout", ["onEquip"] = "equip", ["onDeEquip"] = "deequip", ["onAddItem"] = "additem", ["onRemoveItem"] = "removeitem"}
do
local mt = getmetatable(MoveEvent)
local defaultCall = mt.__call

mt.__call = function(self, params)
-- we need to make sure that the MoveEvent contains a setup table, if not we are using an outdated version
if not params then
print("You are using scripts with an outdated version of revscriptsys (MoveEvent)")
print(string.format(">> file: %s\n", debug.getinfo(2, "S").source))
return defaultCall(self)
end
-- we are adding the table params with the parameters onto self without calling __newindex
MoveEventRegister = params
return defaultCall(self)
end
end

-- hooking the callback function to c
-- if not we are just adding it as a regular table index without calling __newindex
do
local function MoveEventNewIndex(self, key, value)
-- we need to make sure that we are pushing something as a callback function
if type(value) == "function" then
-- we know now that it is a function and hook it in c
-- checking for outdated revscriptsys
if MoveEventRegister then
-- looking if event has been set so we can directly hook
if MoveEventRegister.event then
-- eventType is set through our config table
self:event(MoveEventRegister.event)
self[MoveEventRegister.event](self, key, value)
else
-- we get the type through the hook name
for k, v in pairs(eventList) do
if key:lower():find(k:lower()) then
-- found the right event and hook it
self:event(v)
self[k](self, key, value)
end
end
end
else
self:event(eventList[key])
self[key](self, key, value)
-- using outdated version, we just gracefully return
return
end
-- now that we know that we have a hooked event we want to pass the params and register

-- some prior checks to see if there are ids/uids/aids/pos set
local checks = {"id", "aid", "uid", "pos"}
local found = false
for i = 1, #checks do
if MoveEventRegister[checks[i]] then
found = true
break
end
end

-- making aware that there is no ids set if that's the case
if not found then
print("There is no id/aid/uid/pos set for this callback: ".. key)
return
end

-- we are safe to go now as we are sure that everything is correct
for func, params in pairs(MoveEventRegister) do
if type(params) == "table" then
self[func](self, unpack(params))
else
self[func](self, params)
end
end

-- now we are registering, which frees our userdata
alreadyRegistered = true
self:register()
-- resetting the global variable which holds our parameter table
MoveEventRegister = false

return
end
rawset(self, key, value)
end
rawgetmetatable("MoveEvent").__newindex = MoveEventNewIndex
end
70 changes: 70 additions & 0 deletions data/lib/004register/spell.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local SpellRegister = false
do
local mt = getmetatable(Spell)
local defaultCall = mt.__call

mt.__call = function(self, params)
-- we need to make sure that the Spell contains a setup table, if not we are using an outdated version
if type(params) == "number" then
print("You are using scripts with an outdated version of revscriptsys (Spell)")
print(string.format(">> file: %s\n", debug.getinfo(2, "S").source))
return defaultCall(self, params)
end
-- we are adding the table params with the parameters onto self without calling __newindex
SpellRegister = params
return defaultCall(self, params)
end
end

-- hooking the callback function to c
-- if not we are just adding it as a regular table index without calling __newindex
do
local function SpellNewIndex(self, key, value)
-- we need to make sure that we are pushing something as a callback function
if type(value) == "function" then
-- we know now that it is a function and hook it in c
self:onCastSpell(key, value)

-- checking for outdated revscriptsys
if not SpellRegister then
-- using outdated version, we just gracefully return
return
end
-- now that we know that we have a hooked event we want to pass the params and register

-- some prior checks to see if there are words set
if not SpellRegister.name then
print("There is no name set for this callback: ".. key)
return
end

-- we are safe to go now as we are sure that everything is correct
for func, params in pairs(SpellRegister) do
if func == "vocation" then
if type(params[1]) == "table" then
for k, v in pairs(params) do
self:vocation(unpack(v))
end
else
self:vocation(unpack(params))
end
else
if type(params) == "table" then
self[func](self, unpack(params))
else
self[func](self, params)
end
end
end

-- now we are registering, which frees our userdata
self:register()
-- resetting the global variable which holds our parameter table
SpellRegister = false

return
end
rawset(self, key, value)
end
rawgetmetatable("Spell").__newindex = SpellNewIndex
end
Loading