Hi guys
I have a problem with the tumbleweed template
to enter the character must give a ticket at the entrance.
I can't do this thing.
I also read here
https://www.adventuregamestudio.co.uk/forums/index.php?topic=57962.0
but I don't get out of it
It works for me when I do this:
// GIVE TO
else if (Verbs.UsedAction(eGA_GiveTo)) {
if (Verbs.GetItemGiven() == iKeyCard) cHologram.Say("Thanks!");
else {
player.Say("Do you want this?");
cHologram.Say("I have no pockets.");
}
}
What have you tried? How did it fail? Etc?
where do you enter the code?
In the function handling the character's "any click" event.
in global script?
Yes, characters are global entities, so that is where AGS creates the function when you create the event link by clicking the [...] button.
I'm honestly a bit concerned by your asking these questions, how did you add other interactions so far?
i resumed the project after a year and i feel insecure :cry:
Oh no, sorry, I didn't mean to disturb you; I had no idea about that pause.
Quick recap:
Use the "any click" event for all interactions. Select an object, hotspot or character, click the âš¡ icon to switch from the properties to the events, select the "any click on..." event, then click the small [...] button that appears at the end of the text field next to the event name. Clicking the ellipses button will create the function and take you to it, so you don't have to worry about where to create it.
Inside the function, use the example code provided in the template to tell AGS how to react based on which verb was used.
You should also definitely take a look at the PDF that comes with the template; you can find it inside your game project folder.
Example code for a cup (room object):
Spoiler
function cup_AnyClick() {
// LOOK AT
if (Verbs.UsedAction(eGA_LookAt)) {
player.Say("It's a blue cup.");
}
// USE
else if (Verbs.UsedAction(eGA_Use)) {
player.Say("I'd rather pick it up.");
}
// PICKUP
else if (Verbs.UsedAction(eGA_PickUp)) {
player.Say("Okay.");
Verbs.AnyClickWalkLookPick(108, 100, eDir_Up, "You are now mine.", oCup.ID, iCup);
}
//USE INV
else if (Verbs.UsedAction(eGA_UseInv)) {
Verbs.Unhandled();
}
// don't forget this
else Verbs.Unhandled();
}
Don't worry, you have not offended me, on the contrary it is a stimulus to grow.
I'm experimenting thanks for the info
Quote from: Khris on Tue 08/02/2022 17:21:27
Oh no, sorry, I didn't mean to disturb you; I had no idea about that pause.
Quick recap:
Use the "any click" event for all interactions. Select an object, hotspot or character, click the âš¡ icon to switch from the properties to the events, select the "any click on..." event, then click the small [...] button that appears at the end of the text field next to the event name. Clicking the ellipses button will create the function and take you to it, so you don't have to worry about where to create it.
Inside the function, use the example code provided in the template to tell AGS how to react based on which verb was used.
You should also definitely take a look at the PDF that comes with the template; you can find it inside your game project folder.
Example code for a cup (room object):
Spoiler
function cup_AnyClick() {
// LOOK AT
if (Verbs.UsedAction(eGA_LookAt)) {
player.Say("It's a blue cup.");
}
// USE
else if (Verbs.UsedAction(eGA_Use)) {
player.Say("I'd rather pick it up.");
}
// PICKUP
else if (Verbs.UsedAction(eGA_PickUp)) {
player.Say("Okay.");
Verbs.AnyClickWalkLookPick(108, 100, eDir_Up, "You are now mine.", oCup.ID, iCup);
}
//USE INV
else if (Verbs.UsedAction(eGA_UseInv)) {
Verbs.Unhandled();
}
// don't forget this
else Verbs.Unhandled();
}
I have 6 tickets with different destinations.
I have activated 6 different hotspots that are activated if I give the associated ticket
how can they be put together?
function cControllore_AnyClick() {
function cControllore_AnyClick() {
// GIVE TO
if (Verbs.UsedAction(eGA_GiveTo)) {
if (Verbs.GetItemGiven() == iTicketxxx1)
player.Say("Ecco il mio biglietto");
cControllore.Say("Bene puoi andare!");
cControllore.Say("Il treno per xxx1 sta per partire");
player.LoseInventory(iTicketxxx1);
Verbs.MovePlayer(155, 120);
if (Verbs.GetItemGiven() == iTicketxxx2)
player.Say("Ecco il mio biglietto");
cControllore.Say("Bene puoi andare!");
cControllore.Say("Il treno per xxx2 sta per partire");
player.LoseInventory(iTicketxxx2);
Verbs.MovePlayer(155, 120);
ecc
} else {
cControllore.Say("Non lo voglio");
}
}
}
First of all: you need to put these commands inside a {} block.
The bad way:
if (...)
CommandA();
CommandB();
Here CommandB is always executed, only CommandA() is conditionally executed based on the test.
Here's the correct way:
if (...) { // opening curly brace
DoSomething(); // conditional commands inside the block
DoSomethingElse(); // more conditional commands
DoEvenMoreStuff(); // more conditional commands
} // closing curly brace
Secondly, I'm not seeing any lines related to hotspots.
Thirdly, are you asking how to shorten the code so you don't have six more or less identical blocks of code?
it is theoretically .. the idea is not to create 6 rooms for train departure and 6 rooms for arrival
------
I enter the room
I speak to the stationmaster
tells me to buy the ticket
I go to the ticket office
change of room
there are 6 different destinations
I buy a ticket
I give it to the stationmaster
change of room
arrival at destination
everything is managed by the iTicketxxx
Right. There's no need to create six rooms for that. You can simply store the destination in a global variable.
Use a single room, a single ticket inv item, etc.
Create a global int called "destination" or something.
When you buy the ticket, after the user has picked the destination, use
destination = 1;
to store the choice. Whenever the choice is relevant, use the variable. For instance when looking at the ticket:
function iTicket_OtherClick() {
if (Verbs.UsedAction(eGA_LookAt)) {
if (destination == 1) player.Say("It's a train ticket to Bologna.");
else if (destination == 2) player.Say("It's a train ticket to Rome.");
}
else Verbs.Unhandled();
}
(code not optimized in any way)
You can also write a function that returns the name of the destination:
String TrainDestination() {
if (destination == 1) return "Bologna";
if (destination == 2) return "Rome";
...
}
Now you can use that like:
player.Say("It's a train ticket to %s.", TrainDestination());
not bad. thank you