[Memhack] StorageObject - Redacted-Rice/ITB-RedactedRiceExts GitHub Wiki
Memhack StorageObject
The Memhack StorageObject struct represents an item in the game's storage system. Each object can be either a Pilot or a Skill.
It has the standard memhack base struct functions/fields.
Note: Setters for skill and pilot pointers are not supported. These are smart pointers with additional data that needs to be managed, so they are read-only.
Table of Contents
Data
| Field | Type | Offset | Description |
|---|---|---|---|
| skill | pointer (untyped) | 0x114 | Pointer to a Skill object (currently untyped) |
| pilot | pointer (Pilot | [memhack] Pilot) | 0x11C | Pointer to a Pilot object |
Data Functions
These are functions that draw from the data in the struct or set the data in the struct
Constants
getSkillPtr
intStorageObject:getSkillPtr()
Returns the raw pointer to the skill object. Returns 0 if this storage object is not a skill.
Example:
local item = storage:getAt(1)
local skillPtr = item:getSkillPtr()
if skillPtr ~= 0 then
LOG(string.format("Skill pointer: 0x%X", skillPtr))
end
getPilot
PilotStorageObject:getPilot()
Returns the Pilot struct if this storage object contains a pilot. Returns nil or an invalid pilot if this is not a pilot.
Example:
local item = storage:getAt(1)
if item:isPilot() then
local pilot = item:getPilot()
LOG("Pilot name: " .. pilot:getName())
end
getPilotPtr
intStorageObject:getPilotPtr()
Returns the raw pointer to the pilot object. Returns 0 if this storage object is not a pilot.
Example:
local pilotPtr = item:getPilotPtr()
if pilotPtr ~= 0 then
LOG(string.format("Pilot pointer: 0x%X", pilotPtr))
end
isPilot
booleanStorageObject:isPilot()
Returns true if this storage object contains a pilot (pilot pointer is non-zero).
Example:
local item = storage:getAt(1)
if item:isPilot() then
LOG("This is a pilot")
end
isSkill
booleanStorageObject:isSkill()
Returns true if this storage object contains a skill (skill pointer is non-zero).
Example:
local item = storage:getAt(1)
if item:isSkill() then
LOG("This is a skill")
end
isType
booleanStorageObject:isType(objType)
| Argument name | Type | Description |
|---|---|---|
objType |
string | Type to check: "Pilot" or "Skill" |
Returns true if this storage object is of the specified type.
Example:
if item:isType(memhack.structs.StorageObject.TYPE_PILOT) then
LOG("This is a pilot")
end
getType
stringStorageObject:getType()
Returns the type of this storage object: "Pilot", "Skill", or "Unknown".
Example:
local itemType = item:getType()
LOG("Item type: " .. itemType)
TYPE_PILOT
string= "Pilot"
Constant representing the pilot type for use with isType() and comparisons with getType().
TYPE_SKILL
string= "Skill"
Constant representing the skill type for use with isType() and comparisons with getType().