Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

5
How do *you* structure your state machines?
Post Flair (click to view more posts with a particular flair)
Post Body

I've been experimenting at lot with how to organize my entity parent objects for flexible future use in other projects.

At the moment, I'm playing around with having state functions in a separate script, and storing their ID in a simple array, calling them with script_execute. I'm finding I like this because it lets me open the states script in a side window to the object's event window, as a way of accessing and see Step Event codes, unlike, say, a switch statement that would need to be scrolled up to see or hidden in a region.

Create:

state = ENTITY_STATES.NORMAL;


states[ENTITY_STATES.NORMAL] = functionStateNormal; 

Step:

script_execute(states[state]);

I wish GM still let you store functions in enums.

What's your personal code style at the moment for states?

Author
Account Strength
100%
Account Age
8 years
Verified Email
No
Verified Flair
No
Total Karma
10,687
Link Karma
3,459
Comment Karma
7,172
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago