StoneCypher / fsl

Finite State Language specification
9 stars 1 forks source link

Is it possible to create wildcard transitions? #1217

Open distantforest1 opened 2 years ago

distantforest1 commented 2 years ago

So what's the feature? To be able to transition into a state from any other state. Or Forcibly set a state.

A possible solution to this (an example from a different library): https://github.com/jakesgordon/javascript-state-machine/blob/master/docs/states-and-transitions.md#wildcard-transitions It's not typescript though so I'd rather not use it.

Is this related to a problem? If so, what? I'm using states for a player character over a multiplayer network. For the main player it will have strict transitions. However for the other connected clients, the states might come out of order since it is over the internet. If the foreign client somehow gets out of sync it will be incorrectly displayed as some transitions may not occur in the correct sequential order.

I'll need a way to forcibly set a state if this happens.

Describe the solution you'd like A way to write a wildcard transition, or a way to force transitions without needing to write out every single transition possible. forced_transition() seems close, but it seems to require the forced arrow notation ~> to be defined beforehand.

Describe alternatives you've considered Painstakingly write out every possible transition :/

Additional context as you see fit

// Maybe something like this
const wildcard = sm`* ~> Blue;` // Can transition from any state to 'Blue'
StoneCypher commented 2 years ago

You're right, this needs to exist. It does not, currently. I will repair this promptly.