Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Elevater Challenge.
Elevater Challenge.
2004-05-25, 5:24 PM #1
yea, ive looked around some, through posts, and gobs, i couldn't find much concerning this exact thing, but im needing help with finding a cog that supports my elevater that will go to about 8 floors (at max), with the ability to Hit a surface to make the elevater go to that frame, (floor), and also so you can go on another floor and hit the switch and it comes to that floor, im kinda getting confused how to switch floors without getting out and going back in, so i will also need an adjoin to activate it, im guessing this will be a pretty big cog, and im also guessing someone has made one in the past that i could possibly use in my level, if you dont know of one already, this would be more then helpful. It would be one of the main cogs in my level and you WILL be credited! thank you everyone for you time!

------------------
Your Owners Clan Leaader,
_yo_wasup_
-=__/¯¯l¤¥Ø¤l¯¯\__\/\/ª≤uÞ_=-
http://www.TeamYo.org
2004-05-26, 6:30 AM #2
Hi!
I think I can help you there... First off, you need "Waffers... Lots of waffers..."
"And chips."
"And bear!"
Wrong... What you need, is one elevator, 2 switch things, and a COG...
Code:
# An elevator with buttons.
#
# By Edward
symbols

message		startup
message		activated
message		touched

thing		elevator
thing		switchup	mask=0x405
thing		switchdown	mask=0x405

surface		switch0		mask=0x405
surface		switch1		mask=0x405
surface		switch2		mask=0x405
surface		switch3		mask=0x405
surface		switch4		mask=0x405
surface		switch5		mask=0x405
surface		switch6		mask=0x405
surface		switch7		mask=0x405
surface		switch8		mask=0x405
surface		switch9		mask=0x405
surface		switch10	mask=0x405
surface		switch11	mask=0x405
surface		switch12	mask=0x405
surface		switch13	mask=0x405
surface		switch14	mask=0x405
surface		switch15	mask=0x405

int		floor=0
int		maxfloors

end
#
code
startup:
	MoveToFrame(elevator,floor,100);
	MoveToFrame(switchup,floor,100);
	MoveToFrame(switchdown,floor,100);
return;
activated:
	for(i=0; i<=maxfloors; i=i+1)
	{
		SetWallCel(switch0,0);
		If(GetSenderRef()==switch0)
		{
			floor=i;
			print("Comming!");
			MoveToFrame(elevator,floor,4);
			MoveToFrame(switchup,floor,4);
			MoveToFrame(switchdown,floor,4);
			SetWallCel(switch0,1);
		}
	}
	If(GetSenderRef()==switchup)
	{
		If(floor==maxfloors)
		{
			print("You can't go further");
			return;
		}
		floor=floor+1;
		for(i=0; i<=maxfloors; i=i+1) SetWallCel(switch0,0);
		SetWallCel(switch0[floor],1);
		jkStringConcatAsciiString("Floor: ");
		jkStringConcatint(floor);
		jkStringOutput(-3, -1);
		jkStringClear();
		MoveToFrame(elevator,floor,4);
		MoveToFrame(switchup,floor,4);
		MoveToFrame(switchdown,floor,4);
	}
	else If(GetSenderRef()==switchdown)
	{
		If(floor==0)
		{
			print("You can't go further...");
			return;
		}
		floor=floor-1;
		for(i=0; i<=maxfloors; i=i+1) SetWallCel(switch0,0);
		SetWallCel(switch0[floor],1);
		jkStringConcatAsciiString("Floor: ");
		jkStringConcatint(floor);
		jkStringOutput(-3, -1);
		jkStringClear();
		MoveToFrame(elevator,floor,4);
		MoveToFrame(switchup,floor,4);
		MoveToFrame(switchdown,floor,4);
	}
	else if(GetSenderRef()==elevator)
	{
		jkStringConcatAsciiString("Floor: ");
		jkStringConcatint(floor);
		jkStringOutput(-3, -1);
		jkStringClear();
	}
return;
touched:
	If(GetSourceRef()==GetLocalPlayerThing()) return;
	for(i=0; i<=maxfloors; i=i+1)
	{
		SetWallCel(switch0,0);
		If(GetSenderRef()==switch0)
		{
			floor=i;
			MoveToFrame(elevator,floor,4);
			MoveToFrame(switchup,floor,4);
			MoveToFrame(switchdown,floor,4);
			SetWallCel(switch0,1);
		}
	}
	If(GetSenderRef()==switchup)
	{
		If(floor==maxfloors)
		{
			return;
		}
		floor=floor+1;
		for(i=0; i<=maxfloors; i=i+1) SetWallCel(switch0,0);
		SetWallCel(switch0[floor],1);
		MoveToFrame(elevator,floor,4);
		MoveToFrame(switchup,floor,4);
		MoveToFrame(switchdown,floor,4);
	}
	else If(GetSenderRef()==switchdown)
	{
		If(floor==0)
		{
			return;
		}
		floor=floor-1;
		for(i=0; i<=maxfloors; i=i+1) SetWallCel(switch0,0);
		SetWallCel(switch0[floor],1);
		MoveToFrame(elevator,floor,4);
		MoveToFrame(switchup,floor,4);
		MoveToFrame(switchdown,floor,4);
	}
return;
end

OK. Now, I've added mask flags because this is going into a level of mine where the AI gets to press the buttons. Well, they don't press the buttons, they simply walk into them, and then walk over to some other place.
Anyway, you need an elevator, add frames to it (frame0=bottom floor), then add 2 switch things and put them side by side and add frames to them so they follow the elevator.
int floor = starting floor.
surface switch0-15 are the calling switches that you put outside the elevator shaft. Now, I haven't put on doors. What I did was add door things with their own door COG. So you activate a door to open it, activate a switch to go to a new floor, and then activate a new door to get out.

Hope this is what you need...

/Edward
Edward's Cognative Hazards
2004-05-26, 2:19 PM #3
Just a thought but I've found floor levels are easier to deal with if you assign the "switches" a linkid in the symbols section; you can then evaluate an incremental linkid within a certain range fairly easily, for example (as in you'd want to opimise this for MP -client/server maybe?-, but several key principles remain...):

Code:
##
#
# 00_centralElevControl.COG
#
# Managed server-side, central elevator script.
#
# This COG script is NOT supported by LucasArts or LEC.
#
# Permission is granted to use this script by the author, as long as credit
# is provided in the readme file for any add-on levels that use this script.
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##


symbols

message startup
message activated

surface callSwitch0     linkid=1
surface callSwitch1     linkid=2
surface callSwitch2     linkid=3
surface callSwitch3     linkid=4

surface upSwitch0       linkid=5
surface upSwitch1       linkid=6
surface upSwitch2       linkid=7
surface upSwitch3       linkid=8

surface downSwitch0     linkid=9
surface downSwitch1     linkid=10
surface downSwitch2     linkid=11
surface downSwitch3     linkid=12

int     currentFloor             local
int     floorNum=0              local
int     upFloor=0                local
int     downFloor=0            local

sound   switchSnd

thing   elev            nolink

flex    moveSpeed=8.0
int     numOfFrames=2


int     verbose=0

end


code

startup:

    currentFloor = GetCurFrame (elev);
    MoveToFrame (elev, 0, moveSpeed);
    Return;


activated:

    if ( (GetSenderID() > 0) && (GetSenderID() <= 4) ) {
        call bringToFloor;
    }
    else
    if ( (GetSenderID() > 4) && (GetSenderID() <= 8) ) {
        call moveElevUp;
    }
    else
    if ( (GetSenderID() > 8) && (GetSenderID() <= 12) ) {
        call moveElevDown;
    }
    else {
        if (verbose)
        Print ("BUG !!!");
        Return;
    }

    Return;


bringToFloor:

    if (IsMoving (elev) )
        Return;

    floorNum = GetSenderID() - 1;
    MoveToFrame (elev, floorNum, moveSpeed);
    currentFloor = GetCurFrame (elev);

    PrintInt (currentFloor);

    Return;


moveElevUp:

    if (currentFloor >= numOfFrames) {
        currentFloor = currentFloor - 1;
        Return;
    }

    if (IsMoving (elev) )
        Return;

    currentFloor = currentFloor + 1;
    MoveToFrame (elev, currentFloor, moveSpeed);

    PrintInt (currentFloor);

    Return;


moveElevDown:

    if (currentFloor <= 0)
        Return;

    if (IsMoving (elev) )
        Return;

    currentFloor = currentFloor - 1;
    MoveToFrame (elev, currentFloor, moveSpeed);

    PrintInt (currentFloor);

    Return;

end


For my demo level, I used only four frames (0-3), but the effect of this way of thinking should be clear to see [http://forums.massassi.net/html/smile.gif].

...I hope... [http://forums.massassi.net/html/wink.gif]

Hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX

"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)

And he's finally off the starting grid --> Zooooom -@%
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||

↑ Up to the top!