Skip to content

Allow faction records to be accessed from lua

Zackhasacat requested to merge zackhasacat/openmw:faction_expose_lua into master

As requested in !2949 (merged)

This MR allows you to access faction data from lua.

You can do so like so, from the console with any lua mode enabled:

core.factions: this will return the table containing all the factions that are loaded.

core.factions["mages guild"].name: This will give you the name of the mages guild.

core.factions[1].id: This will give you the ID of the first faction.

core.factions["mages guild"].ranks[1]: This will give you the first rank of the Mages guild, in string form.

core.factions["mages guild"]:getMembership[player]: This will give you the rank of the player, or -1 if they are not in the faction.

The documentation is added. This is pretty bare for now.

I had originally set up core.factions.records to hold the faction records, but there was no other class so didn't see a reason to make a class with one member. However, if creating factions is something we want to be able to do, we would need a "createFaction" or createRecordDraft to be held somewhere.

Edited by Zackhasacat

Merge request reports