Unknown Problem With Hotspot Script

Started by Sriipvood, Fri 05/02/2021 23:41:42

Previous topic - Next topic

Sriipvood

Hi,
I have a problem with a Hotspot Script that i can't figure out.
I'm just a beginner and unfortunately have no clue about scripting, but by following the tutorials i somehow got myself 2 rooms connectet through Hotspots, and it worked (hurray!).
So next I created room 3 and made a hotspot in room 2 as a door just like the first time, copying the script i used before, which i knew was working...
here is the room script of room 2:

Code: ags

// room script file
bool say_once = false;
function room_FirstLoad()
{
}
function hAusgang_AnyClick()
{
if (Verbs.UsedAction(eGA_WalkTo))  player.EnterRoom(1, 139, 159, eDirectionDown);
}
function hToilet_AnyClick()
{
if (Verbs.UsedAction(eGA_WalkTo))  player.EnterRoom(3, 170, 140, eDirectionDown);
}

Since the functions seem to be the same i cant understand why one is working but the other one is not(hAusgang is the one working and hToilet is the one that doesnt)... This is my first attempt at this so I guess the problem is probably something obvious, sorry if this got answered before. thanks in advance  :kiss:

Crimson Wizard

#1
Please, always clarify what "does not work" means, because there's a lot of things that may be implied there (nothing happens, it runs but causes error, it runs but something different or unexpected happens, and so on).

To begin with something I'll assume most simple reason. Make sure these functions are linked to actual events in the hotspot's event table.

There's a related part of tutorial: https://adventuregamestudio.github.io/ags-manual/acintro3.html
and screenshot showing where do you put function names: https://adventuregamestudio.github.io/ags-manual/images/acintro3_02.png

There's a good way to test if your function is run at all: place Display command inside like this:
Code: ags

function hToilet_AnyClick()
{
Display("It runs!");
if (Verbs.UsedAction(eGA_WalkTo))  player.EnterRoom(3, 170, 140, eDirectionDown);
}

If you don't see a message then it's 99% function not connected to event. If it displays, then there's something wrong with the commands inside your new function.

Sriipvood

#2
I'm sorry i forgot the details. it simply didnt react to a click at all, which probably was because i didnt link it to an event like you mentioned.
I actually (more by accident while fooling around) tried the event button. since then I can enter room 2 from room 1, but once i try entering room 3 or 1 i get this error:
QuotePrepare_Script: Error -18 (No such Function in Script) trying to run `room_Leave´(Room2)
.
I tried to delete the hToilet Script, (No changes made on the hAusgang Script) but i still get the error  :confused:
I guess i should start over, Thank You for your answer and the Tips, If i ever solve this I'll update you  :smiley:
edit: I deleted the room2 script and startet over, I got the "It runs!" message but i still get -> Error -18 (No such Function in Script)

Crimson Wizard

#3
Quote from: Sriipvood on Sat 06/02/2021 01:20:27
QuotePrepare_Script: Error -18 (No such Function in Script) trying to run `room_Leave´(Room2)
.

The error message giving you a tip to what function it's related ('room_Leave').
This kind error usually means that you have some function name set in the events table, but at the same time it's not found in script itself. To fix this simply remove room_Leave from the events table.

Your events table should correspond to what you have in script.

SMF spam blocked by CleanTalk