model#
为了能实现用 Python 来操作 SDM 插件的 SavedVariables/SuperDuperMacro.lua 文件,
我们要对 .lua 文件中的代码块进行数据建模, 定义一些 Python 类来代表这些代码块, 然后实现将
Python 对象转化为 .lua 代码块的逻辑.
- class wow_wtf_manager.exp.e03_wotlk.sdm.model.SDMCharacter(name: str, realm: str)[source]#
代表 Character Macro 专有宏命令中关于角色信息的部分. 对应着如下代码块:
["character"] = { ["name"] = "charname", ["realm"] = "realmname", },
- class wow_wtf_manager.exp.e03_wotlk.sdm.model.SDMMacro(name: str, character: Optional[SDMCharacter] = None, type: str = 'b', id: int = 0, icon: int = 1, text: str = '')[source]#
定义了一个魔兽世界中的 SDM 宏命令的抽象, 目前只支持 Button + Global 这一种模式.
代表着如下代码块:
{ ["type"] = "f", ["name"] = "macroname", ["character"] = { ["name"] = "charname", ["realm"] = "realmname", }, ["ID"] = 1, ["text"] = "/s hello", ["icon"] = 1, }, -- [1]
- encode_text() str[source]#
Encode macro text to single-ling Lua string. The final string of the macro body in lua has to have only one line.
- classmethod parse_yml(content: str) SDMMacro[source]#
从人类可读写的 yaml 文件中读取数据, 创建
SDMMacro对象.下面是一个示例的 yaml 文件.
name: interrupt character: name: realm: type: b id: # you can find icon id on https://wotlk.evowow.com/?icons icon: description: | cancel casting spell, interrupt enemy casting immediately! text: | #showtooltip /stopcasting /cast Counterspell