Need help moving a object to one point and back have code

Started by Dr Fred Rubacant Edison, Thu 30/11/2006 03:16:05

Previous topic - Next topic

want to move a object to one point in the room and back to the same place it was when you click on it



// script for Object 1 (Poster): Look at object  // just experment
int pos1;
int pos2;


if (pos1==0) {
object[1].SetPosition(438, 111);
pos1=1;
}

 
if (pos1==1) {
object[1].SetPosition(379, 118);
pos1=0;
}

Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Creator

Try this:
Code: ags

// script for Object 1 (Poster): Look at object
int pos1;
int pos2;


if (pos1 == 0) {
object[1].SetPosition(438, 111);
} 

  
 if (pos1 == 1 ) {
object[1].SetPosition(379, 118);
}

if (pos1 < 1) {
  pos1 += 1;
}

if (pos1 == 1)
  pos1 == 0;
}


the code Didnt work  :(

and this part of the code didnt compile  it said undefine sysmbol pos

if (pos 1 == 1)
  pos 1 == 0;
}
Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

Gilbert

#3
Didn't really look into whether the codes work or not, but:


if (pos1 == 1)
Ã,  pos1 = 0;
}

Remember: double '=' is for comparison while single '=' is for assignment, also no space is allowed in variable names.

Edit: Okay, just read your original post, your original codes should sorta work (not Creator's "workaround") , but with some ammendments:

Move the two variable declaration lines OUTSIDE of the "look at object" function, but move them to the top of that room's script instead (otherwise they'll be redeclared and reset whenever the interaction is run). The pos2 variable is not used in your poted codes though (unless it's to be used somewhere else). So:
int pos1=0;
int pos2=0;

Also:
// script for Object 1 (Poster): Look at objectÃ,  // just experment
if (pos1==0) {
object[1].SetPosition(438, 111);
pos1=1;
} else if (pos1==1) {
object[1].SetPosition(379, 118);
pos1=0;
}

(If you didn't add the 'else' the 'if (pos1==1)' part will always be executed)


Some say i need panels! and Some say i dont Need them.   WHERES THE DRUGS I'm going CRAZY. Plus I must have been on Drugs and a Maniac if i was going to name the game Maniacs Mansion.

What was i thinking!!!!!

SMF spam blocked by CleanTalk