Book a Demo

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - idlehanzgray

Pages: [1]
1
General Board / Re: State Machine - Logger example questions
« on: November 12, 2022, 02:52:42 am »
That was super helpful. When I first read the help example I assumed that the COMObject that was being used existed. It does not. So one needs to use a COMObjcect that exists for the creation to be successful.

Also, it never clicked for me that the purpose of the Trace command was to output to the simulation window until I saw your note. The ability to display information about the state, without having to pause and look at variable values is what I was really after.

Thanks!

2
General Board / Re: State Machine - Logger example questions
« on: November 11, 2022, 06:03:39 am »
I guess I should step back and ask, does anyone use COM objects with a state machine in EA?

3
General Board / State Machine - Logger example questions
« on: October 29, 2022, 03:22:32 am »
I was going through the Help and looking at the state machine use of a logger and thought that could be a helpful function. There are times that, rather than perhaps savings the states as they occur - I might want to write the value of variables, etc.

I created a simple state machine (image link below) to test the logger example. I am assuming (as the great body of evidence will show) - that I am stoopit. This state machine reflects that.

In the initial state I set a counter and then use the example code from the help to create my logger. So far, so good. Although I do have a question - is something supposed to happen with logger.Show()? I don't see anything in the console - should I be looking in the windows event viewer?

The in the next state I simply take a random shot - 90% I'm probably stoopit, else... maybe not - in this code snippet below.

if (this.stoopitChance <= 90) {
   logger.log("You are so stoopit")
} else {
   logger.log("Still stoopit... but the help could be better")
}

However, when I hit this instance of logger.log, an error is reflected in the simulation window:

[214175784]      SIMULATION ERROR: logger is undefined Expression: // chances are I'm stoopit - check if we are - log the result

Do I need to create a new COMObject? I would think not. That begs the question, how do I refer to my already instantiated COMObject?

And of course - where is the log?
How would I change this to say, write to a local text file?

https://imgur.com/DtkrdCT

Thanks all!

4
General Board / Re: State Machine - Choice help
« on: October 26, 2022, 12:36:37 am »
Thank you! That assignment operator was indeed tripping me up. If I had a nickel for every time I used = when I needed to use == in my life well... I'd have a lot of nickels.

The state machine now works as intended. I've posted an updated image in the link below for anyone else following along that may have similar challenges.

https://imgur.com/SMYgX4e

5
General Board / Re: State Machine - Choice help
« on: October 25, 2022, 08:14:32 am »
Here's the link to the new image. The triggers are named Vanilla and Chocolate, respectively - and now the guards are once again populated with the JavaScript. I've expanded the capture so that the values of the variables can be seen - and the event window showing the two waiting triggers.

https://imgur.com/FQ5bNpn

6
General Board / Re: State Machine - Choice help
« on: October 25, 2022, 08:04:22 am »
Thanks for the response. I've been playing with different options - one of which is using the javascript in the guard - but it had the same result. I'll redo with the guard and report the image.

7
General Board / State Machine - Choice help
« on: October 25, 2022, 03:29:23 am »
Greetings all - I've been learning about state machines and attempting to follow along on the various tutorial videos and RTFM. However, I've come across a problem with the use of the choice element in a simple state machine that I created (I wanted to create my own simple example to demo how it works).

This is my state machine

Initial
QueueingForIceCream
  • Initialize variables sim.i = 0, weight = 150;
Deciding
  • on entry - I run this snippet to give me a 0 or 1 (vanilla/chocolate)
  • this.iceCreamFlavor = Math.floor(Math.random() * 2);
Choice
Two triggers from Choice are:
  • this.iceCreamFlavor = 0;
  • this.iceCreamFlavor = 1;
Depending on the 0/1 the following states are:
Vanilla - increment weight by 1
Chocolate - increment weight by 1
there is a junction which returns to the Deciding state

My challenge - the state machine works - but - when it gets to Choice - it just sits there. Even though I can check the value of this.iceCreamFlavor and see whether it is a 0 or 1 one - but the states sit in the waiting triggers queue and I have to double-click one of them to get it to fire. I want it to just run automagically.

What am I missing?


Link to image of state machine here: https://imgur.com/a/TY2q95Y

Pages: [1]