How To Have Activation Objects (Levers) Actually Work?

Non-platform specific questions.

How To Have Activation Objects (Levers) Actually Work?

Postby happyjustbecause » Sun Oct 07, 2012 7:18 pm

So, as the title suggests, I am wondering how to have things like levers, buttons, and pressure plates actually activate something nearby. How can I have one clone activate one other clone? I don't want to have an individual actor for one door to open, is there some way to have a system of one clone affecting another? I hope you understand what I mean by this.

Say I want to have an elevator's movement initialized by a lever, how can I have the nearby lever activate the 1 elevator close to the lever? Instead of activating all the other elevator clones. There must be some actor variables that have to come into play right?
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby skydereign » Sun Oct 07, 2012 8:10 pm

I assume you don't remember how to differentiate clones? Actors have a name, cloneindex, and clonename. The clonename is the way you target individual clones. The pause system I had you setup utilizes clonename to target individual clones (send them an activation event). Of course you can just write the actual clonenames instead of creating them with string operations.
Code: Select all
switch(cloneindex)
{
    case 0: // first lever
    SendActivationEvent("elevator.0"); // sends event to first elevator
    break;

    case 1: // second lever
    SendActivationEvent("door.0"); // sends event to first door
    break;

    // and so on
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby happyjustbecause » Mon Oct 08, 2012 12:42 am

Well I remembered the idea of it, not exactly the format on how to type the clonename, but I was kind of wondering about some kind of system that just works without a limit of how many levers/elevators. I guess that method works just as well though.
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby skydereign » Mon Oct 08, 2012 5:35 am

happyjustbecause wrote:Well I remembered the idea of it, not exactly the format on how to type the clonename

If you ever have questions about actor variables or functions, the script reference is a really good place to go (it's where I learned a lot of gE). http://game-editor.com/docs/script_reference.htm

happyjustbecause wrote:I was kind of wondering about some kind of system that just works without a limit of how many levers/elevators

Setting something like that up would be the most complex thing you have ever done in gE, and you would need to create a map editor to do it. The game will at some point have to know which actors activate which. So, either you can directly code it in (the method I suggested), or create a system that links them together via complex variables (which is not very easy to use unless you have a map editor).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby happyjustbecause » Mon Oct 08, 2012 8:52 pm

Oh wow, I didn't know it was that challenging :), I suppose it is asking for a lot, and it's not really necessary, I can just reuse the switches and buttons for different circumstances depending on what game type someone is playing in, and even if that wouldn't work, I could just have a "Stargrab" button and a "Story" button, having different game types is far down the development of the game anyways.
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby happyjustbecause » Mon Oct 08, 2012 9:02 pm

Actually I've been trying to add a simple moving platform in my game, but for both my button and switch, they have 2 states: on and off. How can I make it so that if you press the button to turn it on, it turns on the elevator, and also if you press the button again it turns it off, turning off the elevator. I already have the button's on/off functionality working, but I'm not sure how to turn the moving platform on/off.

Here's my button code:

Button -> Collision -> Any Side of Crescent (or Night Knight)

Code: Select all
switch(state)
{
    case 0: // Button off to on
    animpos=1;
    PlaySound("Beep...");
    state=1;
    break;

    case 1: // Button on to off
    animpos=0;
    PlaySound("Beep...");
    state=0;
    break;
}


Of course you can just write the actual clonenames instead of creating them with string operations.


How can I write their clonename and also set some actor variable to something if there's already a period in front of their name like: myclone.1.xvelocity=100;

That quote probably doesn't imply what I assumed, but what did you mean? :)
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby skydereign » Wed Oct 10, 2012 1:28 am

It seems you don't fully understand how activation events work, but I won't go into it right now. There is another solution to your problem. Do you remember getclone2 and Actor*s? That is how you get a reference to any clone in gE, and by using it, you can change its actor variables. In this case you can use the built in getclone.
happyjustbecause wrote: myclone.1.xvelocity=100;

Code: Select all
Actor* ref = getclone("myclone.1");
ref->xvelocity=100;

// or in one line
getclone("myclone.1")->xvelocity=100;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How To Have Activation Objects (Levers) Actually Work?

Postby happyjustbecause » Thu Oct 11, 2012 1:34 am

Oh yeah, I forgot about the getclone function, I now got what I was desiring to achieve! I don't really need to turn the switch/button off afterwards, that's for puzzle like things, not just turning on an elevator.
For small creatures such as we the vastness is bearable only through love.
-Carl Sagan

Night Knight Development Thread
User avatar
happyjustbecause
 
Posts: 267
Joined: Tue Jul 26, 2011 3:10 pm
Location: Frazier Park, Ca
Score: 15 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron