Set X to actor type when creating an actor.

DJEmergency

  • Posts: 170
Hello. I'm working on my game here using the scene behaviors and I'm looking for a way to "set x of "Actor type" to "Actor Type" when creating. I've included a picture to show the event I'm working on.


MattHutchings

  • Posts: 224
Hi there,
So what you're trying to do is set the actor's X value when it is being created? As this would be done when your actor is created on your scene anyway, so i'm not really too sure on what it is you're asking here. If you're trying to get the actor's X value but you're not on the actor's behaviour then you can use a game number attribute and set this to your actor's X location then you can call it if needed or use it to change the actor's current location. If this isn't what you're after then could you go into a bit of detail on what your looking to do?

Hope this helps,
Matt.

letmethink

  • *
  • Posts: 2545
'x' in the case of the OP is just a placeholder for any value. I do it this way:
Code: (pseudocode) [Select]
when created
    for each actor of type (normal door) (actor of type:
        if <(for (actor of type),  get _DoorNumber from behaviour DoorActors) == (DoorInformation)>
            Do stuff
        endif
    endfor
~Letmethink

DJEmergency

  • Posts: 170
Sorry I'll explain better on what I'm doing.

In the game you have doors that the player can go through and when the player goes into one you move to a different scene. Each set of doors has a value and every time you collide with a door it sets a global value to the door's value. (I did this because a scene can have more than one door and I needed a way to know which door he went through.) So my goal is...

When doors are created:
--> If door value matches global value.
----->  Position player to the door with the matching values.

t4u

  • Posts: 418
Draw it becuas eI dont understnad it :(
USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/

DJEmergency

  • Posts: 170
Imagine the first scene has 3 doors and each door leads to a different scene (example: enter into door1 you go to scene 2. enter into door2 you go to scene 3. etc..)

Since the doors use the same actor I make them different by using an attribute value for each door. When the player collides with the door it changes the global attribute with the collided door's value.

So what I'm doing is... when the doors are being created during the level it compares the global attribute to the door's attribute. Then I want to position the player to the door with the matching attributes.

DJEmergency

  • Posts: 170

t4u

  • Posts: 418
Scene 2 (I don't knwo how many doors it has so I assume 2)

Create door actor
Set actor 1 to LAst created actor
Create door actor
Set actor 2 to LAst created actor
Create player  at 0,0
Set player  to LAst created actor

If <global>=1
  set x,y to (x,y-20) of actor 1

If <global>=2
  set x,y to (x,y-20) of actor 2

Is that what you want?

USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/

DJEmergency

  • Posts: 170
Scene 2 (I don't knwo how many doors it has so I assume 2)

Create door actor
Set actor 1 to LAst created actor
Create door actor
Set actor 2 to LAst created actor
Create player  at 0,0
Set player  to LAst created actor

If <global>=1
  set x,y to (x,y-20) of actor 1

If <global>=2
  set x,y to (x,y-20) of actor 2

Is that what you want?



Thank you for the reply, but I'm trying to use a single actor for the doors with many instances instead of using many different actors for the doors. This way I don't use up too much resources for my game.


DJEmergency

  • Posts: 170
Maybe it's impossible to do with a scene behavior so I would have to do it as en event inside the scene.

letmethink

  • *
  • Posts: 2545
Code: (pseudocode) [Select]
when created
    for each actor of type (normal door) (actor of type):
        if <(for (actor of type),  get _DoorNumber from behaviour DoorActors) == (DoorInformation)>
             create player at x (x of actor of type) y (y of actor of type)
       endif
    endfor

Does this not work? (just added in the last line now I know what you want to do)
~Letmethink

DJEmergency

  • Posts: 170
Code: (pseudocode) [Select]
when created
    for each actor of type (normal door) (actor of type):
        if <(for (actor of type),  get _DoorNumber from behaviour DoorActors) == (DoorInformation)>
             create player at x (x of actor of type) y (y of actor of type)
       endif
    endfor

Does this not work? (just added in the last line now I know what you want to do)


Thank you so much for the reply. Yes! This is what I'm trying to do. Is this code I can paste into a code block?

letmethink

  • *
  • Posts: 2545
No, it is pseudo-code, but all the blocks are in Stencyl and can be searched for (I refer to them by name).
~Letmethink

DJEmergency

  • Posts: 170
No, it is pseudo-code, but all the blocks are in Stencyl and can be searched for (I refer to them by name).

Oh I thought it was a code. Yea this doesn't work because it doesn't allow me to pick an attribute or actor type in the scene behavior..

letmethink

  • *
  • Posts: 2545
Picking an actor type does work in a scene behavior (picking an actor is more difficult). Be more specific about the problem. Have you written out my code. Attach a screen-shot of what you have got.
~Letmethink