Draft: Lua Spells and MagicEffects
I need control of spells and effects via lua for my mod. This task seems to have been inactive for some months. I've been exploring it to become familiar with this portion of the engine.
Putting this draft up a bit early to hopefully get a couple more experienced eyes on it. I'm new to the project.
High level usage as I have it functioning currently:
- types.Spell.record(id)
- types.MagicEffect.record(id)
- types.Actor.spells(self)
- types.Actor.spells(self):getAll()
- types.Actor.activeSpells(self):getAll()
- other methods like clear(), add(), remove(), etc
Example, expanded table as returned by types.Actor.activeSpells.get methods:
table: 0x0c55dbe8 {
1 = table: 0x0c4e81c0 {
worsenings = -1,
id = lady's favor,
type = 1,
effects = table: 0x0c55b310 {
1 = table: 0x0c568d08 {
arg = 6,
duration = -1,
id = 79,
timeLeft = -23762.6484375,
magnitude = 25,
maxMagnitude = 25,
index = 0,
minMagnitude = 25,
flags = 3,
}
},
name = Lady's Favor,
casterActorId = 3,
}
}
Some smells and questions so far:
- do these definitions belong in the types package?
- do the local accessors belong in NPC instead of Actor?
- this is specific to ESM3 structs; is that bad?
- when to use tables, when to use userdata