[Behavior] State Machine

Post your completed addons to share with the community

Post » Tue Feb 17, 2015 2:37 am

Message: anpur can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Hi,

As first addon to build I've developed State Machine behavior, which tracks state and emits proper events if it changes.
GitHub: https://github.com/anpur/c2-state-machine
Download: http://goo.gl/SxoBYA

With given functions you can decouple events which changes your object state and logic, how you object reacts on those changes.
You can have several state machines per object, e.g. Mood ('sleeping', 'patrolling', 'fighting') and Weapon ('ready', 'aiming', 'firing', 'reloading').

Events on specific state transitions can help you build animation more easily.
For example: On Moster.Mood transition from sleep to attack set animation 'attack from lair'.

Features:
    - In state condition: checks that machine in particular state.
    - On state change trigger: occurs when state changed.
    - On state entering trigger: occurs when entering particular state.
    - On state leaving trigger: occurs when leaving particular state.
    - On state transition trigger: occurs on transition from one particular state to another.
    - Set state action: set current state.
    - State expression: returns current state.
    - Previous state expression: return previous state.
    - Initial state property: to set initial state of machine.
    - Ignore same property: ignores attempts to set same state as current.

I hope this behavior will be useful for someone :)
I'm still working on example project.

P.S. - I realize, that this is not the first state machine addon, but I wanted to write it so much.
B
7
S
1
Posts: 15
Reputation: 457

Post » Tue Feb 17, 2015 2:51 am

I had made one before.
B
100
S
22
G
197
Posts: 4,216
Reputation: 113,822

Post » Tue Feb 17, 2015 3:08 am

Thanks for sharing this. The more choices the better :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Feb 17, 2015 10:11 pm

Thanks :)
B
46
S
16
G
9
Posts: 1,096
Reputation: 11,153

Post » Tue Mar 03, 2015 11:25 pm

AWESOME!
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
53
S
14
G
4
Posts: 160
Reputation: 7,535

Post » Sat Sep 12, 2015 10:12 pm

anpur wrote:Features:
    - In state condition: checks that machine in particular state.
    - On state change trigger: occurs when state changed.
    - On state entering trigger: occurs when entering particular state.
    - On state leaving trigger: occurs when leaving particular state.
    - On state transition trigger: occurs on transition from one particular state to another.
    - Set state action: set current state.
    - State expression: returns current state.
    - Previous state expression: return previous state.
    - Initial state property: to set initial state of machine.
    - Ignore same property: ignores attempts to set same state as current.


those expression look so awesome .. and simple to use.. i wander can i use it with a multiplayer system? i mean does it brake the exporting methods? or is it stable?
Image
B
57
S
16
G
64
Posts: 1,260
Reputation: 39,825

Post » Tue Oct 06, 2015 8:06 am

Made my C2 not even load. have to uninstall manually.

Code: Select all
---------------------------
Construct 2 Check failure
---------------------------
Check failure!  This is probably a bug:

ACE table: Expression ID duplicated in ACE table

Condition: exp_ids.find(id) == exp_ids.end()
File: c:\c2\source\exporters\html5\..\..\common\ERAHelpers.h
Line: 269
Function: void __cdecl era::ACETable::AddExpression(int,int,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,const class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &,void (__cdecl *)(const class era::StaticResult **,int,class era::StaticEvaluation *))
Build: release 214 (64-bit) checked
Component: HTML5 exporter
(Last Win32 error: 0)

You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way.  Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports!  Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.
---------------------------
Abort   Retry   Ignore   
---------------------------
B
28
S
8
G
4
Posts: 767
Reputation: 5,940

Post » Fri Oct 09, 2015 4:15 pm

@jojoe It's a simple fix. In "edittime.js", there are two expressions with the ID 0, simply change the second entry to 1 and it will work.
B
54
S
21
G
20
Posts: 871
Reputation: 15,450

Post » Fri Oct 09, 2015 4:21 pm

@Magistross,

Thank you!
B
28
S
8
G
4
Posts: 767
Reputation: 5,940

Post » Sun Oct 18, 2015 5:34 am

@anpur Hey I have been meaning to stop by here and thank you for this plugin but it keeps slipping my mind. So, Thank you! Very easy and straightforward to use, very very helpful!
Twitter: https://twitter.com/pudgyplatypus

Learn to make a clicker game for cheap!
https://www.scirra.com/store/games-with ... e-game-666

Try out Pixel Golf on the Scirra Arcade!
https://www.scirra.com/arcade/sports-ga ... el-golf-67

Pudgy Platypus Games website!
www.pudgyplatypus.com
B
53
S
16
G
5
Posts: 206
Reputation: 6,826

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest