I think is complecated!! I used AGS 3.1
The question:
I have a room and in the room a object " a ball" (1) to pick up. I will that the character can pick up the object "ball" (1), only if, after the character give a inventory item (bombom) to a object "cat" (2), and the cat move in a new position, the character can pick up the object "ball" (1), else the character say "I can't pick up". How can solve??
I've think for a "set global" or a "Object.GetAtScreenXY" or there is aanother command the I know??
My code:
\\ character give inventory item (bombom) and the object "cat" (2) move to a new position
if (UsedAction (A_USE_INV)){
if (MovePlayer (301, 95)) {
FaceDirection (player.ID, DIR_RIGHT);
Wait (5);
PlaySound(35);
character[16].LoseInventory(iInventory14);
object[1].SetView(52, 0);
while (object[1].Moving) Wait(20);
object[1].Animate(0, 1, eRepeat, eNoBlock);
object[1].Move(360, 80, 1, eBlock, eAnywhere);
object[1].StopAnimating();
object[1].SetView(50, 0);
while (object[1].Moving) Wait(20);
object[1].Animate(0, 1, eRepeat, eNoBlock);
\\character pick up a object " a ball" (1) "the code is incomplete"
if (UsedAction (A_PICK_UP)) {
if (MovePlayer (325,134)){
\\ must I put a "set global" or a "Object.GetAtScreenXY" command??
FaceDirection (GetPlayerCharacter (), DIR_RIGHT);
Wait (5);
AddInventory (10);
PlaySound (4);
ObjectOff (0);
}
else {
DisplaySpeech(GetPlayerCharacter(), "I can't pick up.");
}
}
HELP ???
Open the Global variables pane, then create a new bool variable. Name it "cat_has_bombom" and set its initial value to false.
After you gave the bombom to the cat, use
cat_has_bombom = true;
When the player tries to pick up the ball:
if (cat_has_bombom) {
// player picks up ball here
}
else {
player.Say("I can't pick up the ball.");
}
(Older versions of AGS used SetGlobalInt() and GetGlobalInt() to do the same thing; best forget about those as quickly as possible :))
Also, PLEASE use [code] tags and indent your code properly.
Thanks Chris for your HELP! Very Great!!
I've see that the new version of AGS is great!! (I've study bool variable ;D).
But there is also something that dosn't work!!
The code work in part....I've set bool and...
At first, when I pick up the ball....not work
After give bombom cat I pick the ball...work
mmmmm....what is wrong??
After Char give the bombom to the cat, I've used code:
Code:
if (UsedAction (A_USE_INV)){
if (MovePlayer (301, 95)) {
FaceDirection (player.ID, DIR_RIGHT);
Wait (5);
PlaySound(35);
character[16].LoseInventory(iInventory14);
cat_has_bombom = true; \\ here I've just lose inventory item 14 (giving bombom)
object[1].SetView(52, 0);
while (object[1].Moving) Wait(20);
object[1].Animate(0, 1, eRepeat, eNoBlock);
object[1].Move(360, 80, 1, eBlock, eAnywhere);
object[1].StopAnimating();
object[1].SetView(50, 0);
while (object[1].Moving) Wait(20);
object[1].Animate(0, 1, eRepeat, eNoBlock);
Char pick up:
if (UsedAction (A_PICK_UP)) {
if (cat_has_bombom) {
if (MovePlayer (325,134)){
FaceDirection (GetPlayerCharacter (), DIR_RIGHT);
Wait (5);
AddInventory (10);
PlaySound (4);
ObjectOff (0);
Wait (5);
player.Say("A ball.");
}
else {
player.Say("I can't pick up the ball.");
So, what doesn't work?
I thought this is what you wanted, the player can't pick up the ball, only after they gave the bombom to the cat.
Here's how you're supposed to code it:
if (UsedAction(A_PICK_UP)) {
// always move the player to the ball
if (MovePlayer(325, 134)) {
FaceDirection(player.ID, DIR_RIGHT);
Wait(5);
if (cat_has_bombom) {
player.AddInventory(10);
PlaySound(4);
oBall.Visible = false; // you can use a name instead of object[0]
Wait(5);
player.Say("A ball.");
}
else {
player.Say("I can't pick up the ball.");
}
}
}
Great!! :D
Thanks Chris