Make API for creating potions
Created a new API package openmw.records. This package is only available to global scripts.
Its purpose is to provide the API surface for creating records into the world database.
Initially it only supports potions.
This MR adds two functions to the package:
-
createPotion- Takes a lua table with the properties of an
openmw.types.Potion. - Creates a new potion record with those properties.
- Takes a lua table with the properties of an
-
findPotion- Takes a lua table with the properties of an
openmw.types.Potion. - Tries to find an existing custom potion record with those properties, ignoring the icon and mesh.
- This allows you to create new potions without spamming the database with identical records by accident. This is the logic by which the alchemy system creates potions.
- Takes a lua table with the properties of an
Note: The openmw.types.Potion type does not currently support the list of effects, so for now this entry point can
only create potions with no effects.
Note: I did not find a way to refer to dynamically generated potions from the Console, so I added logic that parses
id:s like $generated123 as generated ID:s. This may or may not be a sane thing to do, but I'll leave it here
for now because it is helpful in testing.
Example:
local records = require('openmw.records')
local potion = {}
potion.name = "Null Potion 1"
potion.weight = 0.1
potion.value = 10
potion.icon = "icons\\m\\tx_potion_exclusive_01.dds"
potion.model = "m\\Misc_Potion_Exclusive_01.nif"
local existing = records.findPotion( potion )
if( existing == nil ) then
potion = records.createPotion( potion )
print( 'Created: ' .. tostring( potion ) )
else
print( 'Found existing: ' .. tostring( existing ))
end
Edited by Mitten Orvan