ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Nov 14, 2018 1:36 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Addon HELP please .....
PostPosted: Tue Sep 26, 2017 2:23 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
I've been working on this addon for months and lots of it works but I am pulling my hair out trying to get my new version of the default projector to work.

The code seems right to me and I've studied other addons in detail, but for some reason, my damage_types.lua code for the default projector doesn't load :-(

In desparation, I am posting my draft addon here, in the hope someone will be kind enough to work out what I am doing wrong.

This addon can't be used with many other addons by the way, so would need to be tested alone, but embers, orcs, possessors, and vault all loaded.

here is my load.lua:
Code:
-- Verbose. This is the way to load a new damage_types.lua file
local DamageType = require "engine.DamageType"
local ActorTalents = require "engine.interface.ActorTalents"

_G.vb_indent = ""

class:bindHook("ToME:load", function(self, data)
      DamageType:loadDefinition("/data-verbose/damage_types.lua")
      ActorTalents:loadDefinition("/data-verbose/talents/steam/butchery.lua")
      ActorTalents:loadDefinition("/data-verbose/talents/chronomancy/temporal-combat.lua")
      ActorTalents:loadDefinition("/data-verbose/talents/chronomancy/flux.lua")
      ActorTalents:loadDefinition("/data-verbose/talents/cursed/gestures.lua")
      ActorTalents:loadDefinition("/data-verbose/talents/cursed/force-of-will.lua")
end)


here is my init.lua:
Code:
long_name = "Verbose"
short_name = "verbose"
for_module = "tome"
version = {1,5,5}
weight = 115 -- needs to be higher than Embers (= 10)
author = { 'jenx' }
homepage = "http://tome.te4.org/"
description = [[This addon inserts much more information in the log about damage reduction.]]
tags = {'info'}
hooks = true
overload = true
superload = true
data = true


here is the start of my damage_types.lua:
Code:
local print = print
if not config.settings.cheat then print = function() end end

-- The basic stuff used to damage a grid
setDefaultProjector(function(src, x, y, type, dam, state)
   if not game.level.map:isBound(x, y) then return 0 end

   print("BLAH BLAH BLAH") --v
   sf = string.format --v
   --local vb_indent_init = _G.vb_indent --v
   --_G.vb_indent = _G.vb_indent.."  "
...


Here is my folder structure:
\data
\data\damage_types.lua
\data\talents
\data\talents\chronomancy
\data\talents\chronomancy\flux.lua
\data\talents\chronomancy\temporal.combat/lua
\data\talents\cursed
\data\talents\cursed\force-of-will.lua
\data\talents\cursed\gestures.lua
\data\talents\steam
\data\talents\steam\butchery.lua
\hooks
\hooks\load.lua
\overload
\overload\mod
\overload\mod\class
\overload\mod\class\interface
\overload\mod\class\interface\Combat.lua
\superload
\superload\mod
\superload\mod\class
\superload\mod\class\Actor.lua
init.lua

Thanks in advance!!!!

Attachment:
tome-verbose.zip [55.3 KiB]
Downloaded 13 times

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Tue Sep 26, 2017 5:18 pm 
Offline
Wayist

Joined: Wed Jan 07, 2015 7:51 pm
Posts: 27
You want to replace the existing setDefaultProjector() right? Then you should superload it instead of just having it in data. Just loading a file doesn't make tome call any functions in it. Try taking it out of your hooks, moving it to \superload\data\DamageTypes.lua and changing it to start with
Code:
local _M = loadPrevious(...)

local print = print
if not config.settings.cheat then print = function() end end

local super_setDefaultProjector = _M.setDefaultProjector
_M.setDefaultProjector(function(src, x, y, type, dam, state)
     -- rest of code


That will make it so every time tome calls DamageTypes.lua:setDefaultProjector it will instead call your version of it.


Top
 Profile  
 
PostPosted: Tue Sep 26, 2017 11:58 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
Ok. I'll try that tonight and get back to you.

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Wed Sep 27, 2017 9:44 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
Dienes wrote:
You want to replace the existing setDefaultProjector() right? Then you should superload it instead of just having it in data. Just loading a file doesn't make tome call any functions in it. Try taking it out of your hooks, moving it to \superload\data\DamageTypes.lua and changing it to start with
Code:
local _M = loadPrevious(...)

local print = print
if not config.settings.cheat then print = function() end end

local super_setDefaultProjector = _M.setDefaultProjector
_M.setDefaultProjector(function(src, x, y, type, dam, state)
     -- rest of code


That will make it so every time tome calls DamageTypes.lua:setDefaultProjector it will instead call your version of it.


This didn't work. I also tried adding return _M to the end of damage_types.lua, and it still didn't work.

Also, I looked at 10 other addons that modify damage_types.lua - they all do it the way I did originally, loading through load.lua etc...

Any other suggestions?

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Thu Sep 28, 2017 10:41 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5768
DamageType:loadDefinition(stuff) is only designed for adding/altering damage types, not for changing functions.

You will need to use a superload or similar to alter the function code.

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Fri Sep 29, 2017 2:50 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2263
HousePet wrote:
DamageType:loadDefinition(stuff) is only designed for adding/altering damage types, not for changing functions.

You will need to use a superload or similar to alter the function code.


Actually I solved it by using loadDefinition. I studied every addon that changes the projector and they all do it this way. Perhaps it's because it is not a function? Anyway, it's working now and I'm stoked.

_________________
MADNESS rocks


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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