Avoid unnecessary signal definition

* Don't generate button cube signal if -1 or omitted
* Require button press, door, and box dropper signals to be specified
This commit is contained in:
Matt Penny 2024-03-02 21:58:21 -05:00
parent cd72779930
commit 6a1a7994b9
3 changed files with 10 additions and 10 deletions

View file

@ -5,15 +5,15 @@ A flat, circular button which emits a [signal](../signals.md) while pressed.
## Name structure
```
@button PRESS_SIGNAL_NAME OBJECT_PRESS_SIGNAL_NAME
@button PRESS_SIGNAL_NAME [OBJECT_PRESS_SIGNAL_NAME]
```
## Arguments
| Name | Description |
| -------------------------- | --------------------------------------------------------- |
| `PRESS_SIGNAL_NAME` | The name of the signal to emit while pressed |
| `OBJECT_PRESS_SIGNAL_NAME` | The name of the signal to emit while pressed by an object |
| Name | Description |
| ------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `PRESS_SIGNAL_NAME` | The name of the signal to emit while pressed |
| `OBJECT_PRESS_SIGNAL_NAME` (optional) | The name of the signal to emit while pressed by an object. Use `-1` or omit to indicate no signal. |
## Notes

View file

@ -134,7 +134,7 @@ void buttonUpdate(struct Button* button) {
targetPos.y -= BUTTON_MOVEMENT_AMOUNT;
signalsSend(button->signalIndex);
if (shouldPress == PRESSED_WITH_CUBE) {
if (button->cubeSignalIndex != -1 && shouldPress == PRESSED_WITH_CUBE) {
signalsSend(button->cubeSignalIndex);
}

View file

@ -17,7 +17,7 @@ for _, dropper in pairs(sk_scene.nodes_for_type('@box_dropper')) do
table.insert(box_droppers, {
position,
room_index,
signals.signal_index_for_name(dropper.arguments[1] or ''),
signals.signal_index_for_name(dropper.arguments[1]),
})
end
@ -33,8 +33,8 @@ for _, button in pairs(sk_scene.nodes_for_type('@button')) do
table.insert(buttons, {
position,
room_index,
signals.signal_index_for_name(button.arguments[1] or ''),
signals.signal_index_for_name(button.arguments[2] or ''),
signals.signal_index_for_name(button.arguments[1]),
signals.optional_signal_index_for_name(button.arguments[2])
})
end
@ -75,7 +75,7 @@ for _, door in pairs(sk_scene.nodes_for_type('@door')) do
position,
rotation,
world.find_coplanar_doorway(position) - 1,
signals.signal_index_for_name(door.arguments[1] or ''),
signals.signal_index_for_name(door.arguments[1]),
parse_door_type(door.arguments[2])
})
end