Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1x 1x 1x 3x 3x 1x 2x 2x 2x 2x | /** * Exports object instance toggle switch variable value function. * * @module object-instance/switches/toggle-switch-value.function */ import type { AgtkObjectInstance } from '@agogpixel/pgmmv-ts/api/agtk/object-instance/object-instance'; import { ObjectInstanceAccessorType } from '../object-instance-accessor-type.enum'; import { resolveId } from '../resolve-id.function'; /** * Toggle switch value in object instance. * * @param objectInstance Object instance. * @param key Switch ID or name. * @returns Toggled switch value or `undefined`. */ export function toggleSwitchValue(objectInstance: AgtkObjectInstance, key: number | string) { const id = resolveId(objectInstance, ObjectInstanceAccessorType.Switches, key); if (id === -1) { return; } const container = objectInstance.switches.get(id); const newValue = !container.getValue(); container.setValue(newValue); return newValue; } |