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.

ForumsDiscussion Forum → need some help with a COG
need some help with a COG
2011-11-17, 1:09 PM #1
OOOOOK! so i am trying to make a cog for a puzzle...thing, for a level i am doing over at the jkhub.
everything works fine and dandy except for the last part! the part at the end that is commented out with the forward slashes (//) stops the script from running at all... any thoughts??
Code:
symbols


message    activate


thing    lever0    linkid=0
thing    lever1    linkid=1
thing    lever2    linkid=2
thing    tile0    nolink
thing    tile1    nolink
thing    tile2    nolink
thing    door0
    
flex    movespeed=2.0
flex    waittime=2.0


int    currentstop=0    local
int    currentstop1=0    local
int    correntstop2=0    local


end
# ========================================================================================


code


activate:


    if (GetSenderId(GetSenderRef()) == 0) {
        MoveToFrame(lever0, 1, movespeed);
        Sleep(waittime);
        MoveToFrame(lever0, 0, movespeed);
        currentstop = currentstop+1;
        if (currentstop == 3) {
            currentstop = 0;
            }
        MoveToFrame(tile0, currentstop, movespeed);
        }
    if (GetSenderId(GetSenderRef()) == 1) {
        MoveToFrame(lever1, 1, movespeed);
        Sleep(waittime);
        MoveToFrame(lever1, 0, movespeed);
        currentstop1 = currentstop1+1;
        if (currentstop1 == 3) {
            currentstop1 = 0;
            }
        MoveToFrame(tile1, currentstop1, movespeed);
        }
    if (GetSenderId(GetSenderRef()) == 2) {
        MoveToFrame(lever2, 1, movespeed);
        Sleep(waittime);
        MoveToFrame(lever2, 0, movespeed);
        currentstop2 = currentstop2+1;
        if (currentstop2 == 3) {
            currentstop2 = 0;
            }
        MoveToFrame(tile2, currentstop2, movespeed);
        }
    //if (currentstop == 0) &&
       //(currentstop1 == 2) &&
       //(currentstop2 == 1) {
            //MoveToFrame(door0, 1, movespeed);
            //}
    return;
    
end
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-17, 1:13 PM #2
"currentstop2" is mispelled in your symbols section as "correntstop2".

This thread should really be in the Cog Forum.
And when the moment is right, I'm gonna fly a kite.
2011-11-17, 1:14 PM #3
This thread has been rated U due to unreasonable demands.
Star Wars: TODOA | DXN - Deus Ex: Nihilum
2011-11-17, 1:14 PM #4
I know jack all about cog, but if it's like any other programming language I've used in the past many years, the if statement is borked.

if (currentstop == 0 && currentstop1 == 2...) {MoveToFrame(door0, 1, movespeed);


Basically, you were putting the additional comparisons outside the if statement instead of inside it.
2011-11-17, 1:39 PM #5
Code:
symbols
    message  activate
    message  arrived
    message  timer
    thing    lever0    linkid=0
    thing    lever1    linkid=1
    thing    lever2    linkid=2
    thing    tile0     linkid=3
    thing    tile1     linkid=4
    thing    tile2     linkid=5
    thing    door0
    flex     movespeed=2.0
    flex     waittime=2.0
    int      i=0       local
    int      f=0       local
end
code
activate:
    i = GetSenderID(GetSenderRef());
    if(i < 0 || i > 2) stop; // only respond to levers
    if(IsThingMoving(lever0)) stop; // ignore message if lever is moving
    MoveToFrame(lever0, 1, movespeed);
    SetThingTimer(lever0,waittime);
    stop;

timer:
    i = GetSenderID(GetSenderRef());
    MoveToFrame(lever0, 0, movespeed);
    f = GetCurFrame(tile0); // find out where the tile is
    if(f == 3) f = -1;
    StopThing(tile0); // stop the tile if it's moving
    MoveToFrame(tile0, f+1, movespeed);
    stop;

arrived:
    if(GetSenderID(GetSenderRef()) < 3) stop; // only respond to the tiles
    if((GetCurFrame(tile0) == 0)
  && (GetCurFrame(tile1) == 2)
  && (GetCurFrame(tile2) == 1)
    )
    {
  MoveToFrame(door0, 1, movespeed);
    }
    stop;
end


I'm at the office, so I can't test it, but it should work.
I reworked it a little so that there's no code duplication, and I got rid of the Sleep call (sleeps are never a good idea in setups like this: they don't prevent the user from starting the action again and mucking things up).[/COLOR]
And when the moment is right, I'm gonna fly a kite.
2011-11-17, 2:19 PM #6
thanks GBK! that is awesome! im going to test it out now.

yeah, sorry i would have put it in the COG forum, but i didn't know if anyone went there anymore.
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-17, 2:49 PM #7
I love this thread. Reminds me of when gbk helped me out on a cog and I managed to totally annoy him with my ignorant remarks. Good times! :v:

Damn, that's it, I'm going to fish out my old Nar Shaddaa project and get to it. JK editing is so much fun.
ORJ / My Level: ORJ Temple Tournament I
2011-11-17, 4:37 PM #8
YES! finish it. :D
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob
2011-11-18, 9:14 AM #9
alright GBK i started a thread for a new cog in the cog forum just for you.
Welcome to the douchebag club. We'd give you some cookies, but some douche ate all of them. -Rob

↑ Up to the top!