Addon superloading quest files

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
Pseudoku
Low Yeek
Posts: 8
Joined: Tue Apr 12, 2016 6:29 pm

Addon superloading quest files

#1 Post by Pseudoku »

Currently I'm overloading quests files for my addons, but I'm trying to see if I can avoid conflicts with other addons.

Is it possible to superload the data/quests files?

Ex. The brotherhood-of-alchemists.lua file defines competition function as:

Code: Select all

competition = function(self, player, other_alchemist_nums)
	...
end

Following the wiki doesn't seem to work
(placed in superload/data/quests/brotherhood-of-alchemists.lua)

Code: Select all

local _M = loadPrevious(...)
local base_competition = _M.competition

function _M:competition(player, other_alchemist_nums)
  ...
end

return _M
Also tried assigning the competition reference like

Code: Select all

_M.competition = function(self, player, other_alchemist_nums)
or

Code: Select all

competition = function(self, player, other_alchemist_nums)

I looked at the base functions of other superloaded mods but the functions are all declared like

Code: Select all

function _M:onQuit()
Does the function have to be declared like that to superload it?

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: Addon superloading quest files

#2 Post by darkgod »

Ah no you cant. Most datafiles cant be superloaded like that, but can usually be altered otherwise.

Sadly quests kinda can't :/

For 1.5 I've added Quest:init and Quest:setStatus hooks to be able to alter them. With Quest:init you'll be able to simply alter "self" as desired.

As for how to do it in 1.4; you could just superload Quest:init hook in and use that.
To do that just superload engine/Quest.lua:init() method that doest this code:

Code: Select all

	self:triggerHook{"Quest:init"}
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

Re: Addon superloading quest files

#3 Post by Zizzo »

Pseudoku wrote:Currently I'm overloading quests files for my addons, but I'm trying to see if I can avoid conflicts with other addons.
Always a commendable goal. :wink:
Pseudoku wrote:Is it possible to superload the data/quests files?
No, files in data/ can't be superloaded, because that's not really how superloading works. For your particular case, my approach would probably be to superload mod.class.Player:on_quest_grant() to modify the newly installed quest table in place:

Code: Select all

local super_on_quest_grant = _M.on_quest_grant
function _M:on_quest_grant(quest)
  super_on_quest_grant(self, quest)

  if quest.name == 'The Brotherhood of Alchemists' then
    self.quests[quest.id].competition = function(self, player, other_alchemist_nums)
      ...
    end
  end
end
[Fair warning: the above pseudocode is untested. Use at your own risk. We Apologize for the Inconvenience.™]
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply