Addon HELP please .....

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Addon HELP please .....

#1 Post by jenx »

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: Select all

-- 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: Select all

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: Select all

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!!!!
tome-verbose.zip
(55.3 KiB) Downloaded 419 times
MADNESS rocks

Dienes
Wayist
Posts: 27
Joined: Wed Jan 07, 2015 7:51 pm

Re: Addon HELP please .....

#2 Post by Dienes »

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: Select all

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.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Addon HELP please .....

#3 Post by jenx »

Ok. I'll try that tonight and get back to you.
MADNESS rocks

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Addon HELP please .....

#4 Post by jenx »

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: Select all

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

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: Addon HELP please .....

#5 Post by HousePet »

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.

jenx
Sher'Tul Godslayer
Posts: 2263
Joined: Mon Feb 14, 2011 11:16 pm

Re: Addon HELP please .....

#6 Post by jenx »

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

Post Reply