Skip to content

A PartModule contains two fields with the same name, however PartModule:SETFIELD and GETFIELD can set/get the value of only the first occurance. #2939

@mg-badman

Description

@mg-badman

In some cases, modules happen to have fields that have the same name.

In such a case, the SETFIELD and GETFIELD functions will only obtain the first encounter of the field, but completely ignore the second one (or any potential other ones).

example:
with the '24-77 "Twitch" Liquid Fuel Engine'

image

there are two fields named "Throttle"

  • the first field is a Boolean
  • the second is a Float, which can't be accessed in any way via kos

when i run the following command on my ship to observe that engine's ModuleEnginesFX module
print ship:parts[13]:getmodule("ModuleEnginesFX").

the output shows:

ModuleEnginesFX, containing:
LIST of 13 items:
[0] =
["value"] = "(settable) fuel flow, is Single"
[1] =
["value"] = "(settable) prop. requirement met, is Single"
[2] =
["value"] = "(settable) thrust, is Single"
[3] =
["value"] = "(settable) specific impulse, is Single"
[4] =
["value"] = "(settable) status, is String"
[5] =
["value"] = "(settable) throttle, is Boolean"
[6] =
["value"] = "(settable) throttle, is Single"
[7] =
["value"] = "(settable) thrust limiter, is Single"
[8] =
["value"] = "(callable) shutdown engine, is KSPEvent"
[9] =
["value"] = "(callable) toggle engine, is KSPAction"
[10] =
["value"] = "(callable) shutdown engine, is KSPAction"
[11] =
["value"] = "(callable) activate engine, is KSPAction"
[12] =
["value"] = "(callable) toggle independent throttle, is KSPAction"

From the above, entries 5 and 6 are both "throttle". When I attempt to use SETFIELD or GETFIELD, only affects entry 5, the Boolean. Unfortunatelly, because of this I cannot set the throttle of the engine.

I suspect that this may also be the case with KSPAction/KSPEvent entries, if their names repeat within a single PartModule object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions