I made my first interaction. I made an object that can be picked up. But when I run the program, it ignores the open function. What did I do wrong?
This is the script that should let the character talk when you try to open the object.
function oDiskette_Open()
{
Wait(10);
cPaul.SpeechView = 4;
cPaul.Say("I don't want to open this. I might break it.");
}
The software compelled me to make these functions. I have no idea why, where it comes from and if it has something to do with my problem. :(
function oDiskette_Mode8()
{
}
function oDiskette_Mode9()
{
}
AGS doesn't run this function when you click Open on the object just because the function exists and has that name (AGS doesn't really recognize the function names, with a few exceptions). It needs to be "hooked up" to the event. The basic AGS way of doing this is explained here (https://www.adventuregamestudio.co.uk/manual/acintro3.htm).
However, it looks like you're using the Tumbleweed template. Check out the introduction here (https://github.com/adventuregamestudio/ags-manual/wiki/Tumbleweed). So, instead of an
oDiskette_Open() function, you need to create and hook up an
oDiskette_AnyClick() function (the easiest way to do this is to find the "any click on object" event in the object's property pane/event tab and click on it; AGS will create the function for you), and then check which verb was used inside the function.
Quote from: SquirrelMonkey on Sun 23/05/2021 06:47:11
The software compelled me to make these functions. I have no idea why, where it comes from and if it has something to do with my problem. :(
This looks like you've accidentally clicked on the events for mouse mode 8 and 9 in the object's property pane/event tab. You should go in there and delete them, and then delete the functions.
I'll also add one more thing. It's unrelated, but important. When you write code, use indentation. This means starting blocks of lines inside of functions and other control structures (basically, anything between { } curly brackets) with a given number of spaces. (AGS by default uses two spaces for each level of indentation.) Your example should look like:
function oDiskette_Open()
{
Wait(10);
cPaul.SpeechView = 4;
cPaul.Say("I don't want to open this. I might break it.");
}
The AGS editor will automatically indent lines for you after a '{' and unindent after a '}', so almost the only thing you need to do is to not mess with it.
The reason this is important is that it shows the program structure. It makes it easy to see at a glance where a function, a loop or an "if" block begins and ends. It may seem pointless while things are simple like this, but as your code gets longer and more complex, it's essential in order to keep track. Not using indentation in code is like not using paragraphs/line breaks in a message: You end up with an unreadable wall of text.
The Thumbleweed template comes with a PDF (you can find it in the game folder) that details all its features and how certain stuff is done differently from the usual way outlined in the AGS manual's tutorial.
The Tumbleweed docs are also included in the AGS help under F1, that's shipped with the Editor and the online version of the ags-manual is here: https://adventuregamestudio.github.io/ags-manual/Tumbleweed.html#tumbleweed