IncantationsAPI
Developer library for adding new incantations
截圖 共 1 張
模組介紹 作者原文
This is an library to make it easy for developers to add new incantations. It does nothing by itself. You should only install it if another mod requires it.
Developer API Documentation
Quickstart
This guide assumes you're writing a mod based on Hell2Modding/ModUtil. You can check out the Hades2ModTemplate or my other mods for examples.
- Add a dependency to "BlueRaja-IncantationsAPI-1.0.0" to your dependency list in manifest.json
- In main.lua, add the lines
--@module 'BlueRaja-IncantationsAPI'
Incantations = mods['BlueRaja-IncantationsAPI']
`
- In ready.lua, call Incantations.addIncantation(params). See below for details.
- _(If you are not using SGG_Modding-ReLoad, meaning you don't have a ready.lua, then it must be called inside of a ModUtil.once_loaded.game() call)_
Methods
Incantations.isIncantationEnabled(id)
Returns true if the incantation has been purchased by the player; false otherwise.
Parameters:
- id (string) - The same ID passed to addIncantation
Incantations.addIncantation(params)
Adds a new incantation. This method _must_ be called at the start of the time, ie. in ready.lua or inside a ModUtil.once_loaded.game() call.
Parameters:
- params (table) - A table containing the following key-value pairs
- Id (string) (required) - A unique internal ID to reference this incantation by. I'd recommend prefacing it with your username to avoid conflicts. It will not be shown to the players.
- Name (string|table) (required) - The name displayed in the cauldron. Can be either a constant string or a translation table _(see below)_.
- Description (string|table) (required) - The description shown when hovering over the incantation in the cauldron. Can be either a constant string or a translation table _(see below)_.
Descriptions can also contain escape sequences that render special things. Some examples:
- {#Emph} - Causes the following text to be bold. There are other text-formats, which you can find by searching for {#. A particularly special one is {#Prev}, which acts as the closing tag, bringing you back to the previous format.
- {!Icons.GiftPoints} - Will render an image of a Nectar, as well as a box along the side of the screen explaining what "Nectar" is. There are many other icons as well, which you can find by searching for {Icons.. You should use an icon any time you reference a resource (bones, plants, etc) in the description.
- {$Keywords.CharArachne} - Will display "Arachne" in a special color, along with a box along the side explaining who that is. You should use {$Keywords.Char sequences whenever you reference a character in the description. There are also ones for locations, eg. {$Keywords.WellShop} will display "Well of Charon" + the help box.
- FlavorText (string|table) (required) - The flavor text shown in italics below the description when hovering over the incantation in the cauldron. Can be either a constant string or a translation table _(see below)_.
- WorldUpgradeData (table) (required) - The information about the incantation, in the same format as the entries in WorldUpgradeData.lua. This includes cost, requirements, icon, voice lines, etc. _(see below)_.
- OnEnabled (function) (optional) - A function to be called when the incantation is enabled, it when the incantation is first purchased, and also whenever the save file is loaded. The function passed in can optionally take two parameters, in this order:
- source (string, either "load" or "purchase") - Whether the function is being called due to a save file loading ("load") or the incantation being purchased ("purchase").
- incantationId (string) - The ID of the incantation being enabled.
WorldUpgradeData
The WorldUpgradeData passed into addIncantation takes the same format as the entries in WorldUpgradeData.lua. There are dozens of possible properties to choose from, but here are the most important ones:
- Icon (string) - The path to the icon to display on the cauldron screen.
You can find the paths and images by using th
安裝與使用 安裝:按包內說明操作
- 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
- 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
- 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
- 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。
不同模組的安裝位置差異較大,包內說明是最可靠的依據。 Hades II 使用遊戲自帶的 Mod 匯入功能,解壓後的包按 readme 放入指定目錄即可。
下面這些內容需要先安裝,否則該模組不會生效: