Achieved goals:

Current Goal(s):

Further goals:

Current Code

-- located in tome/addons/shriketomepatch/patch.lua
function patch_init()
        message(color.LIGHT_RED, "shriketomepatch patched in sucessfully.")
        hook(hook.INFO_DATA_LOADED, function ()
                message(color.LIGHT_RED, "shriketomepatch hook.INFO_DATA_LOADED hooked sucessfully.")
                
                getter.auto_share_flags(true)
                new_artifact
                {
                        name = "& Breakfast Bag~ of Bilbo"
                        unknown_name = "& bulging bag~"
                        desc = {
                                "A bulging bag emitting delicious smells.",
                                "It clatters, squishes, sloshes, and makes you quite hungry.",
                        }
                        base_object = { tval=TV_LITE, sval=SV_LITE_TORCH_EVER }
                        level = 20 rarity = 10 weight = 10 cost = 10000
                        flags =
                        {
                                ACTIVATE = function(info, obj)
                                        if info then return "just seems to hold food. Lots of food." end
                                        return true, timed_effect.set(timed_effect.FOOD, food.DEFAULT_VALUE - 1)
                                end
                                INSTA_ART = true LITE = 4
                                LITE_SUN = true LUCK = 4
                        }
                }
                getter.auto_share_flags(false)
        end)
        return "shriketomepatch","0.0.8"
end

Chatter

ShrikeDeCil This doesn't seem to work, but I thought I'd put it out there to see what people can say about the mechanics. I know I want to make this a non-light, the old 'tilde' type artifact is what I was aiming for. How, exactly does one add an 'addon'? Just putting it into the addon folder is insufficient. I could hack init.lua to forcibly add it, but if the folder is already pre-designated as an area for addons, it should be scanned, yes?

NeilStevens: 'Addons' is for add-on code, not data.

ShrikeDeCil: Ok... but the whole 'LUAification' has blurred the distinction. That is - there's an awful lot of code in my data. Are all scripts in the Addons folder executed? And can I drop a script in there to... reload the artifacts list?

NeilStevens: The core data structures in data/ are parsed separately, after scripts/init.lua is run (that's the only thing in scripts that's run by the engine. A module's own init.lua must run any other files there). The data is then cached, or will be cached once the engine is out of alpha.

DarkGod: Actually you can, the hook hook.INFO_DATA_LOADED is designed for that. Just put the new_artifact call inside such a hook. Now for your addon to work you need to have:

function patch_init()
        -- Do whatever you want on addon loading here
        -- like installing the aforementionned hook.

        return "Name of your Addon", "Version of your Addon"
end

ShrikeDeCil: Excellent! I put my interpretation of things into code (see above). The patch is loaded, and the hook is called (as reported by the messages)... and then things go south. ERROR in lua_call while calling '____hooks_list_callback303' lua hook

The INFO_DATA_LOADED hook is listed as returning 'nil', so I tried just a bare 'return' instead of the 'Name of your addon' version, same results. I peeked around for awhile today trying to figure out what I'm doing wrong here. I'll work on this some more later, but if there's something stupid I'm doing, I'd appreciate it being pointed out. I expect I'm not hooking properly, or I need to cause a re-chaching or something.

ShrikeDeCil: Heh. I needed "getter.auto_share_flags(true)" wrapping around the new artifact. This actually works in a10. Wizard mode -> create item #17 -> Bilbo's bag.

ShrikeDeCil Having trouble wrapping my head around the two formats for defining new data at the moment. There's the "define_as" method, which works great for stores & whatnot. But the items use a blind array inside another blind array which is making my head hurt.

new_store_action
{
        define_as = "store.ACTION_NONE"
}

versus

new_item_kinds
{
        [TV_FOOD] =
        {
                [SV_FOOD_CAKE] = {
                } -- SV_FOOD_CAKE
        } -- TV_FOOD
} -- new_item_kinds

The issue is that I don't want to redefine [TV_FOOD], I want to append to the end of that array after it was successfully created. Looking in engine/info.lua, the code seems very similar, so I should be able to do this, I guess I need to think about it some more. Pretty sure I can just pop that SV_ into a 'define as', but have to think about how to not redefine TV_FOOD. hum.

ShrikeDeCil: Well, drat. The HOOK trick gets the artifact on the list, and I can create it & use it... but if I "Examine" it, it becomes panicsave time. The artifact on its own (that is, plugged into Tome's artifacts.lua directly) does not have this issue - the problem is with adding new data late somehow.

DarkGod: Now that one is weird. Anything in engine_errors.log ? Mhh I should release alpha11 soon, it has an emergency stacktrace...

ShrikeDeCil: I don't seem to have an "engine_errors.log" anywhere. Mac OS X, ToME-SDL a10. Spotlight didn't turn up anything, so I tried 'sudo find / -iname "engine_errors.log" -print' also. No dice.

ShrikeDeCil: Tome 3a11 now. Retesting produces no engine_errors.log. Pointers on what a normal path for this file might be? And is Tome-SDL-Mac supposed to use graphics? Additionally, the command "I", which used to be 'Inspect" seems to request a keybinding now. So to cause the 'examine' bug, I had to sell the Bag to the black market, then ask to eXamine it from the store options. Boom.

ShrikeDeCil: Stacktrace found. (~username/engine_errors.log). Sort of an odd place, but it works -> no complaints :D

Lua emergency stacktrace:
STACK (0): name(inkey), namewhat(field), curline(-1), linedef(-1), what(C), sour
ce(=C // C)
STACK (1): name(start), namewhat(field), curline(94), linedef(68), what(Lua), so
urce(@/engine/baby.lua // file `/engine/baby.lua')
STACK (2): name(select_module_screen), namewhat(global), curline(560), linedef(5
43), what(Lua), source(@/engine/mods_aux.lua // file `/engine/mods_aux.lua')
Lua emergency stacktrace end. Proceeding to die. Arrrrg!

This is "Examining" a "HOOKed in" addon item sold to the Black Market.

ShrikeDeCil/TomeAddons/Bilbo's Breakfast Bag (last edited 2006-11-12 05:01:38 by ShrikeDeCil)