Accessible Fields

If you liked this item, please rate it up on Steam Workshop page.

Author: albion

Last revision: 26 Sep, 2023 at 21:45 UTC (1)

File size: 37.95 KB

On Steam Workshop

Description:

AccessibleFields is a library for other mods to use, it doesn’t do anything on its own. As an end user, you don’t have any reason to install this unless a mod you use requires it.

This should be as early in your load order as possible.

Modifies the class metatables to allow fields to be accessed with the intuitive object.field syntax we’re all used to. While fields can be accessed without this script, the syntax is extremely cumbersome and unnatural.

Usage Example:
local player = getPlayer() player:Say("The closest zombie is " .. player.closestZombie .. " away."

Please be aware that while it uses the syntax of a table access, it is actually a java function call, and a fairly expensive one at that. In testing, a field access is around 70% more expensive than calling a simple getter. So for performance reasons it is usually best to use field access only for things that do not have getters.

There is currently no support for accessing fields inherited from superclasses. This is simply a limitation of Zomboid’s reflection API and not something I can fix. This is most notable for item objects, which inherit 99% of their fields.

View on GitHub[github.com]

Workshop ID: 3001901955
Mod ID: 00AccessibleFields

Download
Revisions:

Old revisions of this mod are available below. Click the link to download.