Character behavior

Luyren

  • *
  • Posts: 2343
That's because your "SetRandom" is only called after a movement is ended. If your boolean is false when that happens, nothing is calling SetRandom again, so your actor won't move.

Your axis check should not set a boolean to true. Instead, it should constantly set the X and Y positions of the actor back to the limit (if X > 240, set X to 240). That would be the idea.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 258
Thank you so much! I've made it to always set the axis back to a certain number if it surpasses it. Initially, it was still getting stuck, but I removed another set of blocks that were in the movement trigger events (there was an if statement that checks if the pet is more/less than a certain X axis). Removing that makes it much better.

I've attached a screenshot the blocks i've used in case anyone wants to take a look or spots any mistakes.

chongyunxiang

  • Posts: 258
I've faced with another problem, the happiness bar.

I'm trying to tie in the Happy and Hunger bar together. Over time, the Happy bar will reduce. The Hunger bar will also reduce. If the hunger is below 20, the pet will begin starving. When it's starving, the Happy bar will decrease faster.

I'm not sure why what I've done doesn't work and it causes the Happy bar to reduce almost immediately.

Luyren

  • *
  • Posts: 2343
When updating executes 100 times per second. You are triggering "Starving" 100 times per second. I'm sure you can see the problem with that.

Also, on your created event, as soon as the "do every" is triggered once, it will execute til the end of time. You should have that "if"statement inside of it, not outside.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 258
I've gotten the Starving behavior to work! Thanks!

Now when the pet is dirty, it's supposed to Every Few Random Seconds display the dirty emoticon, but it keeps triggering every second. I'm not sure where it went wrong. I tried creating separate behaviors or events for it, but it just keeps triggering every second instead.

Luyren

  • *
  • Posts: 2343
Two things I noticed at a quick glance:
1- You are using multiple Updating events. It's better to use only one, and use the comment blocks to indicate what part refers to what.
2- The bottom Updating event on your screen shot has a "do every" block on the top of it. You are triggering 100 "do every" instances per second, it will throw all your timings out of whack, and likely creating the result you are seeing. Don't use a "do every" in that case.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 258
How do I use List to add and call out Actors?

From the encyclopedia, it shows that you can add things into the List, but how do I add Actors?

Luyren

  • *
  • Posts: 2343

Use this block when adding it to the list. You can, select an actor from the scene designer,  add the last created actor or add "self" to the list, for example.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 258
I'm trying to see if i can add emoticons to a list which the pet can call out.

Example: when the the hunger bar is low, it'll add the hungry emoticon to the List, when the happy bar is low, it'll add sad emoticon to the list. And when its no longer hungry or sad, the emoticon will be removed from the list.

The Actor block adds the last created actor to the list, and i think this wont solve my issue. I'm not only adding happiness and hunger, but also the pet's character, like curiosity when it sees an item, or bored when it has nothing to do.

Has anyone created such a logic before?

Luyren

  • *
  • Posts: 2343
It sound like you want to add an actor type to the list. Just type its name, and use the "actor type with name" block when retrieving it.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

vicevicebingo

  • Posts: 76
I'm trying to see if i can add emoticons to a list which the pet can call out.

Example: when the the hunger bar is low, it'll add the hungry emoticon to the List, when the happy bar is low, it'll add sad emoticon to the list. And when its no longer hungry or sad, the emoticon will be removed from the list.

The Actor block adds the last created actor to the list, and i think this wont solve my issue. I'm not only adding happiness and hunger, but also the pet's character, like curiosity when it sees an item, or bored when it has nothing to do.

Has anyone created such a logic before?
emoticons

Happy side:
Happy (^_^)
Happy + Hungry (show tongue)
Happy + Curious (Eye with light)
Happy + Bored (eyes are rolling left & right...)

Sad side:
Sad (x_x)
Sad + Hungry (Show teeth)
Sad + Curious (Angry)
Sad + Bored (close eyes completely)

Maybe your art (resource)
will solve

chongyunxiang

  • Posts: 258
I tried using List to Add and Remove emoticons based on the Happy level of the pet. However, it crashes when I clicked on the pet to call out emoticons. At times, I'm able to call out 2 or 3 emoticons before it crashes. The crash report says "TypeError: Error #1009: Cannot access a property or method of a null object reference."

What went wrong and how do I fix it?

Luyren

  • *
  • Posts: 2343
Your non-hidden list must be initialized before you can do anything with it. Set it to "create new list" in a created event.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

chongyunxiang

  • Posts: 258
Is it this way? I tried it and the problem still persists. Sry, I'm a but of a cuckoo when it comes to programming.

Luyren

  • *
  • Posts: 2343
Ah, you're using a game attribute. My bad, completely slipped me by. Regular game attributes are not hidden, so you don't have to do that. When you get your #1009, the error window should have the name of the behavior and the line of code that's giving you problem. If you click the preview code tab in your behavior, or the bunocular icon in the bottom right corner, you can see the actual code, look for that line and find the corresponding block. That should give you a better idea of what the problem is.

I can say one thing though: don't use "do every 0 seconds". I'm no sure if that's the culprit but it definitely will cause you troubles. You are already checking if "Emoticon" has value, but instead of last created value, check if "Emoticon" is alive. Remove the "do every" block, keeping the set X and Y position blocks, and place all that in your Update event. You should also use only one Update event per behavior.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter