sorcery  Diff

Differences From Artifact [f0c3989e05]:

  • File sorcery.md — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 18864) [annotate] [blame] [check-ins using]

To Artifact [c2949bfb63]:

  • File sorcery.md — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 18874) [annotate] [blame] [check-ins using]

   142    142   if you need to change `sorcery`'s behavior in a way that isn't possible through modifying the lore, you can create a file `$world/sorcery/finalize.lua` which will be run at the end of the init process and which will have access to all of the machinery created by the various modules of the mod. `worldbuilding.lua` is like `finalize.lua` but it is run before any lore is loaded. finally, `bootstrap.lua` will be run before anything else, including library code, is loaded, but after the core `sorcery` structure and its loading functions have been created.
   143    143   
   144    144   in the unlikely event that the lore-loading process itself is incompatible with the changes you're trying to make, you can create a `loadlore.lua` file that will be run instead of the usual routine. you'll then be responsible for loading all of the game's lore; the default lore will not even be read! this will be most useful if you're loading or generating your own lore from an unusual source, such as somewhere on the network.
   145    145   
   146    146   if you want to write a lore loader but include some of the default lore, you can use the loading function passed to `loadlore.lua`:
   147    147   
   148    148   ```
   149         --- /srv/mt/geographica/loadlore.lua
          149  +-- /srv/mt/geographica/sorcery/loadlore.lua
   150    150   local load_lore, load_module = ...
   151    151   sorcery.data = dofile('load-remote-lore.lua')
   152    152   load_lore {'enchants', 'spells'}
   153    153   ```
   154    154   
   155    155   as you can see here, once the lore is loaded, it is stored in the variable `data`. there is a subtle distinction you need to bear in mind: `data` represents the full set of lore-derived information `sorcery` has to work with, which is not necessarily the same as the lore itself. for example, certain modules could generate extra information and attach them to the entries in the `data` table, which can be (and is) written to at runtime. the one invariant that the `data` table should observe is that once a record is added, it may neither be mutated nor removed (though additional sub-records can always be added) -- `sorcery` is not written to handle such eventualities and it may produce anything from glitches to crashes. the term `lore` references specifically the core records stored on disk from which the `data` table is generated, and a `lorepack` is a full, integrated collection of lore. (there are cases where modifying or deleting from `data` may be necessary for a `sorcery`-aware mod, for instance to prevent players from creating a certain default potion, but this is very fraught and you should only ever do it if you thoroughly understand the internals and exactly what you're doing, with the caveat that what works in this version may break the next.)
   156    156   
................................................................................
   209    209   		description = sorcery.lib.str.capitalize(name) .. ' Extract Keg';
   210    210   		color = sorcery.lib.color(data[2]):hex();
   211    211   		‹···›
   212    212   	})
   213    213   end)
   214    214   ```
   215    215   
   216         -but in the on_metadata_inventory_put code for keg-filling node, to identify the proper keg, we might instead use code like
          216  +but in the `on_metadata_inventory_put` code for keg-filling node, to identify the proper keg, we might instead use code like
   217    217   
   218    218   ```
   219    219   local inv = minetest.get_meta(pos):get_inventory()
   220    220   local fluid = inv:get_stack('fluid',1)
   221    221   if fluid:get_count() < 99 then return end
   222    222   
   223    223   local fname = fluid:get_name()