Hi Guys,
Me again :cool:
Just wanted to see if there is any kind of shortcuts for automatically displaying a message when an action is invalid.
For example I have a room with 10 hotspots inside (sign, door, window etc). For example if the character attempts to 'Push Door' or 'Pull Window' or 'Pickup Sign' do I have to enter an event for every single possible interaction, or is there a shortcut to show that this action is not possible?
Many thanks!
I think what you're looking for is unhandled_event.
Quote from: Matti on Mon 14/06/2021 01:36:40
I think what you're looking for is unhandled_event.
Thanks Matti, yes that's exactly what I was looking for :)
I take it these go into the GlobalScript.asc?
I have some pre inserted code here, do I need to overwrite this with the unhandled events text or add new code?
/* Character, Object, Hotspot full blown SAMPLE
function cChar_AnyClick() {
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// TALK TO
else if (Verbs.UsedAction(eGA_TalkTo)) {
Verbs.Unhandled();
Player.Say("I can't talk to that.");
}
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
Verbs.Unhandled();
}
// OPEN
else if(Verbs.UsedAction(eGA_Open)) {
Verbs.Unhandled();
}
// CLOSE
else if(Verbs.UsedAction(eGA_Close)) {
Verbs.Unhandled();
}
// USE
else if(Verbs.UsedAction(eGA_Use)) {
Verbs.Unhandled();
}
// Push
else if(Verbs.UsedAction(eGA_Push)) {
Verbs.Unhandled();
}
// Pull
else if(Verbs.UsedAction(eGA_Pull)) {
Verbs.Unhandled();
}
// PICKUP
else if(Verbs.UsedAction(eGA_PickUp)) {
Verbs.Unhandled();
}
// GIVE TO (characters only)
else if(Verbs.UsedAction(eGA_GiveTo)) {
Verbs.Unhandled();
}
//USE INV
else if(Verbs.UsedAction(eGA_UseInv)) {
Verbs.Unhandled();
}
else Verbs.Unhandled();
}
*/
/* Inventory SAMPLE
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
Unhandled();
}
// USE
else if(Verbs.UsedAction(eGA_Use)) {
Unhandled();
}
// Push
else if(Verbs.UsedAction(eGA_Push)) {
Unhandled();
}
// Pull
else if(Verbs.UsedAction(eGA_Pull)) {
Unhandled();
}
//USE INV
else if(Verbs.UsedAction(eGA_UseInv)) {
Unhandled();
}
else Unhandled();
*/
Not entirely sure what/where to edit the manual is not exactly clear in this area :tongue:
Yes, you would have a function like this in Global Script:
function unhandled_event(int what, int type) {
if (what == 1) // hotspots
{
if (type == 1) // Look at hotspot
{
}
else if (type == 2) // Interact with hotspot
{
}
...
The help file does have a part about unhandled events in the Tumbleweed template, and it says: "The messages itself are defined outside of this function, initially in TemplateSettings.asc."
The Tumbleweed template comes with a Verbs.Unhandled() function.
Say you have a hotspot, a sign:
function cChar_AnyClick() {
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
player.Say("It's a sign.");
}
// all other actions
else {
Verbs.Unhandled(); // show default unhandled message depending on used verb
}
}
Note that the Tumbleweed template comes with its own manual which details the available functions.
It assumes familiarity with both programming and AGS basics though.
Quote from: Matti on Mon 14/06/2021 11:10:27
Yes, you would have a function like this in Global Script:
function unhandled_event(int what, int type) {
if (what == 1) // hotspots
{
if (type == 1) // Look at hotspot
{
}
else if (type == 2) // Interact with hotspot
{
}
...
The help file does have a part about unhandled events in the Tumbleweed template, and it says: "The messages itself are defined outside of this function, initially in TemplateSettings.asc."
OK. For the life of me I cannot figure this out for the past 2 days :confused:
I've read up all of the documentation I can and searched the forums but still struggling with unhandled events :cry:
I see the notes in the Thimbleweed manual, how do I access Template.Settings.asc? I cannot see that anywhere.
I am putting code inside the GlobalSricpt.asc but nothing is happening...Help me Obi Wan Kanobi, youre my only hope.
Quote from: Khris on Mon 14/06/2021 13:15:16
It assumes familiarity with both programming and AGS basics though.
*Chuckles*
I'm in danger
Quote from: Khris on Mon 14/06/2021 13:15:16
The Tumbleweed template comes with a Verbs.Unhandled() function.
Say you have a hotspot, a sign:
function cChar_AnyClick() {
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// LOOK AT
else if(Verbs.UsedAction(eGA_LookAt)) {
player.Say("It's a sign.");
}
// all other actions
else {
Verbs.Unhandled(); // show default unhandled message depending on used verb
}
}
Note that the Tumbleweed template comes with its own manual which details the available functions.
It assumes familiarity with both programming and AGS basics though.
So if for a sign then this would go into the room script, and not the global script?
I have tried entering this in the global script but nothing happens when interacting with objects or hotspots, really stuck with this :confused:
Functions for room-specific things like objects and hotspots go into the room script, those for characters and inv items go into the global script.
However: you don't have to worry about that because when you create the event handler, AGS puts the function in the correct script for you. You just provide the contents.
You select the object/hotspot/character, open the events tab (lightning bolt icon) then click on the "any click on" event, then click the ellipses button [...]
AGS creates the function, links it to the event and opens the script for you. Now you insert the code.
Note that how to do this for a hotspot is explained in the manual's tutorial, and you're supposed to complete that before using anything more complex.
Quote from: Khris on Tue 15/06/2021 11:49:58
Functions for room-specific things like objects and hotspots go into the room script, those for characters and inv items go into the global script.
However: you don't have to worry about that because when you create the event handler, AGS puts the function in the correct script for you. You just provide the contents.
You select the object/hotspot/character, open the events tab (lightning bolt icon) then click on the "any click on" event, then click the ellipses button [...]
AGS creates the function, links it to the event and opens the script for you. Now you insert the code.
Note that how to do this for a hotspot is explained in the manual's tutorial, and you're supposed to complete that before using anything more complex.
You are amazing, thank you Khris :grin:
I was confused because I thought ALL unhandled events would be included in the global script and you would only add USE, OPEN etc in your room, but now I see the whole script has to go inside each room, for each individual hotpot (or at least that's the way its working for me).
You have helped me nearly complete my first room, thanks alot :) Now onto objects and inventory interactions :=