ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Tue Jan 23, 2018 5:55 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Dec 28, 2016 10:43 pm 
Offline

Joined: Tue Apr 12, 2016 6:29 pm
Posts: 1
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:
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:
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:
_M.competition = function(self, player, other_alchemist_nums)

or
Code:
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:
function _M:onQuit()


Does the function have to be declared like that to superload it?


Top
 Profile  
 
PostPosted: Fri Dec 30, 2016 1:54 pm 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10147
Location: Angolwen
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:
   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 ;)


Top
 Profile  
 
PostPosted: Mon Jan 02, 2017 3:40 am 
Offline
Sher'Tul

Joined: Thu Jan 23, 2003 8:13 pm
Posts: 1429
Location: A shallow water area south of Bree
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:
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..."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group