integers and actors

Does any one know if it is possible to attach an integer to a spawned actor?

Thank you
Richard

Best Answer

  • gyroscopegyroscope I am here.Posts: 6,598
    Accepted Answer
    Hi gyroscope.

    Thanks, but that wont work. Reason being that the spawned actors at the bottom actually swap to a new actor. So there's in essence, nothing to count as every time it is starting over with a new actor.
    OK, I misunderstood what you wanted to achieve.... hopefully @FryingBaconStudios suggestion will sort it for you.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Answers

  • sparkaniasparkania Member, PRO Posts: 300
    you might want to be more specific.. what do you want to do?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    What do you mean by attach? And integer is a variable and an actor is an object. Please be more descriptive in what you want to accomplish.
  • sparkaniasparkania Member, PRO Posts: 300
    I got a stapler..
  • SocksSocks London, UK.Member Posts: 12,822
    I got a stapler..
    : )
  • SocksSocks London, UK.Member Posts: 12,822
    Does any one know if it is possible to attach an integer to a spawned actor?
    Like the others have said the question is a little vague, if you stick to the Gamesalad nomenclature / language it will make it easier for people to help you out (there is no behaviour called 'attach' in GS).

    Or if you don't know what the correct terms are then try and describe what it is you are trying to achieve.
  • belottebelotte Member Posts: 25
    OK... let me see if I can explain this a little better.

    So Atributes (like an integer) are "generic", meaning that once created they are global (any rule on any actor can reference them).

    Is it posible to create an atribute (again... an integer in this case) that is local; meaning it can only be referenced by the rules of one actor.

    That's what I mean by "attached". Does that make sense?

    Thanks,
    Richard
  • sparkaniasparkania Member, PRO Posts: 300
    edited January 2013
    Yes and No.. Yes You can create an Integer which you program to be Used by 1 actor, but not one that can ONLY be used by 1 actor.

    can I assume you are wanting a single actor to be Spawned and use an attribute (integer) which you are not seeing when programming the Prototype?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    @belotte

    Hi Richard, yes, as @sparkania confirmed, you can make an attribute specifically for any one actor; in GSC, these are called self attributes.

    Some info "for the record": there are three types of attributes that can be made in GSC, namely game attributes, scene attributes and self attributes.

    • Game attributes are the equivalent of global variables in something like RealBasic, etc., as you mentioned global. So even when changing scenes, these will be "remembered".

    • Scene attributes are specific to each scene and are the equivalent of a type of local variable made in RealBasic, etc. These don't stay in the memory when moving to another scene, so you can easily have exactly the same type of scene attribute with the exact same name for every scene if you wanted, but all with different values, if required.

    • Self attributes are specific to an actor in a particular scene, and are equivalent to local variables; these are made in the prototype actor in the Inspector, then the value can be changed to suit, once it has been dragged out onto the scene. And like scene attributes, the values of self attributes don't stay in memory if you change scene.

    Hope that's useful for you.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • belottebelotte Member Posts: 25
    Hey there.

    OK that's good to know. Unfortunately that doesn't really help. What I need is an atribute (variable) that is associated with just one spawned actor but can be referenced by another actor.

    Let me explain what I am trying to do. I have actors that are spawned randomly at the bottom of the screen. Each of those individually has 3 stages. So it spawns and stays in the first stage.

    Now, there are actors that are randomly spawned at the top of the screen. When you "click" these, they "shoot" a "beam" down to the actors at the botom.

    If this "beam" hits an actor at the bottom of the screen,the actor at the botom swaps to a new actor; putting it in the next pase of the 3. And then all this again for the third and final stage.

    The problem I have is I cant get the actor at the botom to stop at each phase. On first contact the actor at the bottom progresses straight through the second fase to the last.

    Does that make sens?

    Thanks,
    Richard
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    You need to add lockouts to break up your sequence. Make a self integer and when the beam hits the actor have it add +1 then change the rules to change based on the number in the self attribute. So the second time the beam hits it the number will be 2 and so on.. Right now I am aging since you're using overlap and collide with beam in all the change rules it sets it off like a chain reaction. This will put fire stops between the events.
  • belottebelotte Member Posts: 25
    Hello FryingBaconStudios.

    Thanks for the idea. In theory that works... but there's a problem with that. When the beam hits the actor, it "switches" to a ne actor (second in the sequence), so any self atribute (the intiger in this case) is gone with the previous actor.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @belotte

    Here's another test for you which you can hopefully incorporate the principals into your game. I've made the equivalent of the laser beam draggable for this example. And I've dragged out the prototypes instead of having them spawned, but spawning them it will still work the same way. And I've made a self attribute called Counter in the prototype actor, which decreases by one in each individual copy of the prototype, every time the laser actor touches it.

    Prototype self attributes test:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • belottebelotte Member Posts: 25
    Hi gyroscope.

    Thanks, but that wont work. Reason being that the spawned actors at the bottom actually swap to a new actor. So there's in essence, nothing to count as every time it is starting over with a new actor.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    In your actor instead of swapping it out for another actor change the actors image and it's size to match along with the other method I showed you this will work.
  • belottebelotte Member Posts: 25
    So FryingBacon.

    The count up with an integer (self attribute) didn't work. Still the same problem.

    What did work though is that in conjunction with a global Boolean.

    YEAH!
Sign In or Register to comment.