from transitions import Machine, State

class Matter():
    def say_hello(self):
        print("hello, new state!")
    def say_goodbye(self):
        print("goodbye, old state!")

# ----- START ------
lump = Matter()

# The states
my_states=['solid', 'liquid', 'gas', 'plasma']
#my_states = [ State(name='solid', on_exit = ['say_goodbye']) , 'liquid' , { 'name' : 'gas'}]

#And some transitions between states
my_transitions = [
    { 'trigger': 'melt', 'source': 'solid', 'dest': 'liquid' },
    { 'trigger': 'evaporate', 'source': 'liquid', 'dest': 'gas' },
    { 'trigger': 'sublimate', 'source': 'solid', 'dest': 'gas' },
    { 'trigger': 'ionize', 'source': 'gas', 'dest': 'plasma' }
    ]

machine = Machine(model = lump, states = my_states, transitions = my_transitions, initial = 'liquid')
##machine = Machine(model = lump, states = my_states)
##machine.add_transition('sublimate', 'solid' , 'gas')
##machine.on_enter_gas('say_hello')
##
### Test out the callbacks...
##machine.set_state('solid')
##lump.sublimate()

