Hello all! First of all i'm new to this forum, so excuse me if my questions is a little bit of a mess. (roll) :-[. I have never programmed/scripted anything in my life. I've red the first part of the scripting tutorial of the online manual. And got it working, the example that is, but it was way over my head, forexample when he goes thru the various += or -= i couldn't make any sense out of it, maybe if i re-read it a couple of times it makes sense but as for now i might adress that English is not my native language.
Also watched the youtube videos "how to learn ags" tutorial series, where i've learnt the majority of what i know, however i have huge gaps of scripting knowledge, and i have to be honest the manual is really complicated for me. It started out easy but then quickly jumped in skill level, the second part of the scripting is chinese basically. It almost feels like if someone sorta takes for given that you know the "time tables" instantly. (laugh). However, the youtube videos are slightly outdated and some ideas do not even work anymore, so i'm stuck in a rot.
Here comes various questions, anybody that can shime in on and answer is V E R Y welcomed to do so. The first question is probably a laugh out loud for some of you guys, but that's okay. :grin:
1. Is scripting another word for programming?
2. Is this a bad habit i'm using. I followed the Youtube tutorial series and eventually realised i don't need the edges for changing rooms, my drawn rooms are so tight sometimes that i need to be able to walk that "fine line" and i couldn't get it to work without either a hotspot or a region, but hotspots with the Thumbleweed template names the location (it seems, correct me if i'm wrong), so it was the obvious way to go. So i started to use Hotspots for it instead. What are the advantages/disadvantages versus forexample edges or regions? I get that with regions i can change the tint/saturation of the character which i've used a lot already, so that's great! But other then that?
2. I have a puzzle idea that i want to create that seems impossible to create with the little basic knowledge i have, as i understand it from what little information i've gathered is what needs to be done is someform of global variable. After watching another youtube video named "HOW TO QUICKLY MAKE A SIERRA/LUCASARTS ADVENTURE GAME | Adventure Game Studio Quick Tutorial". I learnt how to do it with an item from the inventory, but in my case. There is no item. It's just a object or two, one for when the cable is in the wall and one laying on the floor. That if using the right command (Player is supposed to pull a plug, the screen should then go blank in the room, when putting the plug back in, the screen should work again. Let me rephrase that whole section for what it is i am going to do, perhaps it's much easier for you guys to get the grasp then. The Puzzle idea in a nutshell is this ==
A computer when entering the room first time is in error mode/state but it's turned on, so the player should be able to look at the screen with it's error (which will probably transition to another room, since i don't know any better! Haha). The reset button is stuck, so the player has to go to the back of the computer, unplug the cable (which should make the object/lights of the screen disappear momentarly). Then plug it in again, now the object should light up the computer screen again, obviously. However Now when the player clicks "look at screen" (All this is happening in the same room, to be clear!) it should instead show a login screen where the player needs to type a correct password. That password should be found in another room, but if the player knows the password before, there should be no need to find out the password in the other room. I hope that was a clear explanation of the puzzle i'm trying to create :)
3. E-block is confusing to me, a lot of people seems to use it on youtube. I was hoping what it does is make the animation none canceable, is that correct? So forexample when me and my friend plays point and click games, many times in dialogs we accidently hit a mouse button and it skips. I want that to NOT be able to happen, at least the first time you hear a dialog, then perhaps you could be able to skip it if it repeats. How would you go on about creating that?
I guess that's enough of questions for now. Perhaps there are too many questions. :-[
Well, that was a mouthful ;)
Welcome to the wonderful world of Scripting...
1, You generally use a Scripting Language for computer programming... Scripting can be said to be Coding... People who say Programming generally mean Scripting or Coding.
2, I prefer Edges to change rooms as it's one less resource to take up but Regions if needs be..
3, Regards the computer.. maybe you don't need to change rooms...once you look at the screen and see error you go to the back and pull plug you could change computer graphic etc etc... Regarding password screen... You will need a gui for this with a label, a Textbox and a button...you will need to script the password check into the button events for it to work...
4, eBlock means a command will run until it ends and the next line of code automatically starts. Generally the mouse cursor will show wait icon..
It's all good stuff... Ask one question at a time and people here will help you.
You might be better off starting with the Sierra-Style Template to make your first game...
Good luck
Hi, and welcome!
Slasher already answered your questions, but since I wrote this out, maybe you'll find a second version helpful.
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
1. Is scripting another word for programming?
Yeah, basically. Technically speaking scripting is a certain
kind of programming, but for our purposes they're pretty much synonymous.
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
2. Is this a bad habit i'm using. I followed the Youtube tutorial series and eventually realised i don't need the edges for changing rooms, my drawn rooms are so tight sometimes that i need to be able to walk that "fine line" and i couldn't get it to work without either a hotspot or a region, but hotspots with the Thumbleweed template names the location (it seems, correct me if i'm wrong), so it was the obvious way to go. So i started to use Hotspots for it instead. What are the advantages/disadvantages versus forexample edges or regions? I get that with regions i can change the tint/saturation of the character which i've used a lot already, so that's great! But other then that?
They are meant for different things:
Hotspots are for triggering events that should happen when you
click on them (or move the mouse over them)
Regions are for triggering events that should happen when the character
walks on them
Edges are for triggering events that should happen when the character
crosses them
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
2. I have a puzzle idea that i want to create that seems impossible to create with the little basic knowledge i have, as i understand it from what little information i've gathered is what needs to be done is someform of global variable. After watching another youtube video named "HOW TO QUICKLY MAKE A SIERRA/LUCASARTS ADVENTURE GAME | Adventure Game Studio Quick Tutorial". I learnt how to do it with an item from the inventory, but in my case. There is no item. It's just a object or two, one for when the cable is in the wall and one laying on the floor. That if using the right command (Player is supposed to pull a plug, the screen should then go blank in the room, when putting the plug back in, the screen should work again. Let me rephrase that whole section for what it is i am going to do, perhaps it's much easier for you guys to get the grasp then. The Puzzle idea in a nutshell is this ==
A computer when entering the room first time is in error mode/state but it's turned on, so the player should be able to look at the screen with it's error (which will probably transition to another room, since i don't know any better! Haha). The reset button is stuck, so the player has to go to the back of the computer, unplug the cable (which should make the object/lights of the screen disappear momentarly). Then plug it in again, now the object should light up the computer screen again, obviously. However Now when the player clicks "look at screen" (All this is happening in the same room, to be clear!) it should instead show a login screen where the player needs to type a correct password. That password should be found in another room, but if the player knows the password before, there should be no need to find out the password in the other room. I hope that was a clear explanation of the puzzle i'm trying to create :)
Sure. So:
-A different room for the computer screen is fine, that's a perfectly normal way to do it.
-When you unplug and replug the computer, you could make an object visible with the new screen state. Clicking that object could potentially bring you to
another "computer screen" room.
-However, as an alternative you could use a global variable as you say, and use the same "computer screen" room and display different things on the screen depending on that variable.
-If the password isn't an inventory item, you probably do need a global variable to keep track of whether the player has it. You can create one called "knowsPassword" of type bool. Then to check whether the player knows the password you write something like:
if(knowsPassword)
{
// TODO: Log in to the computer
}
else
{
// TODO: Say something like "Looks like a need a password"
}
Then in the other room, if the player learns the password you just write:
knowsPassword = true;
Quote3. E-block is confusing to me, a lot of people seems to use it on youtube. I was hoping what it does is make the animation none canceable, is that correct? So forexample when me and my friend plays point and click games, many times in dialogs we accidently hit a mouse button and it skips. I want that to NOT be able to happen, at least the first time you hear a dialog, then perhaps you could be able to skip it if it repeats. How would you go on about creating that?
eBlock and
eNoBlock are alternative ways to run animations and some other actions (the e at the beginning just means that they're "enum" values: a fixed list of options to choose between – in this case block or no-block). The difference is whether the rest of the script "blocks" or not: blocking basically means that it pauses, waiting for the command to finish before it continues on to the next line. When the game is blocked, most interaction is disabled.
Blocking is the easiest way to have a bunch of things happening in order (which is often called queuing actions). (Speech, for example, is blocking: A character says one line, and the game
waits for that line to finish before the next line.)
Speech can be skipped by a key or mousebutton press (depending on your settings), but many blocking commands cannot be interrupted. So to do what you describe with making actions cancellable, they usually need to be non-blocking. However, queuing actions becomes much more difficult that way, so as a newbie I probably wouldn't attempt it.
Quote from: Slasher on Fri 22/02/2019 15:10:47
Well, that was a mouthful ;)
Welcome to the wonderful world of Scripting...
1, You generally use a Scripting Language for computer programming... Scripting can be said to be Coding... People who say Programming generally mean Scripting or Coding.
2, I prefer Edges to change rooms as it's one less resource to take up but Regions if needs be..
3, Regards the computer.. maybe you don't need to change rooms...once you look at the screen and see error you go to the back and pull plug you could change computer graphic etc etc... Regarding password screen... You will need a gui for this with a label, a Textbox and a button...you will need to script the password check into the button events for it to work...
4, eBlock means a command will run until it ends and the next line of code automatically starts. Generally the mouse cursor will show wait icon..
It's all good stuff... Ask one question at a time and people here will help you.
You might be better off starting with the Sierra-Style Template to make your first game...
Good luck
It's funny as for your reply to question 3 that crossed my mind too! But again i'm a complete newbie.
Alltho i enjoyed some sierra titles i'm going in to the toughest area of adventure gaming instantly (or so it seems!), :shocked:
I feel like there have not been any real challenges when it comes to typing out various things the player can say or do about certain objects. But it's when the actual "multitask puzzles" that i want to create comes into play. It's obviously a greater challenge!!
It's actually a game i'm making for a friend and myself, a little bit, haha. He always said we should make a game like "thumbleweed park going around in our town". So i've done so. The walking around is already done, however ofc i want to impress him with a puzzle! :wink: :smiley: Thanks for your reply, and yes a Good Luck is most likely what i need!
Quote from: Snarky on Fri 22/02/2019 15:22:32
Hi, and welcome!
Slasher already answered your questions, but since I wrote this out, maybe you'll find a second version helpful.
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
1. Is scripting another word for programming?
Yeah, basically. Technically speaking scripting is a certain kind of programming, but for our purposes they're pretty much synonymous.
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
2. Is this a bad habit i'm using. I followed the Youtube tutorial series and eventually realised i don't need the edges for changing rooms, my drawn rooms are so tight sometimes that i need to be able to walk that "fine line" and i couldn't get it to work without either a hotspot or a region, but hotspots with the Thumbleweed template names the location (it seems, correct me if i'm wrong), so it was the obvious way to go. So i started to use Hotspots for it instead. What are the advantages/disadvantages versus forexample edges or regions? I get that with regions i can change the tint/saturation of the character which i've used a lot already, so that's great! But other then that?
They are meant for different things:
Hotspots are for triggering events that should happen when you click on them (or move the mouse over them)
Regions are for triggering events that should happen when the character walks on them
Edges are for triggering events that should happen when the character crosses them
Quote from: Olleh19 on Fri 22/02/2019 13:48:13
2. I have a puzzle idea that i want to create that seems impossible to create with the little basic knowledge i have, as i understand it from what little information i've gathered is what needs to be done is someform of global variable. After watching another youtube video named "HOW TO QUICKLY MAKE A SIERRA/LUCASARTS ADVENTURE GAME | Adventure Game Studio Quick Tutorial". I learnt how to do it with an item from the inventory, but in my case. There is no item. It's just a object or two, one for when the cable is in the wall and one laying on the floor. That if using the right command (Player is supposed to pull a plug, the screen should then go blank in the room, when putting the plug back in, the screen should work again. Let me rephrase that whole section for what it is i am going to do, perhaps it's much easier for you guys to get the grasp then. The Puzzle idea in a nutshell is this ==
A computer when entering the room first time is in error mode/state but it's turned on, so the player should be able to look at the screen with it's error (which will probably transition to another room, since i don't know any better! Haha). The reset button is stuck, so the player has to go to the back of the computer, unplug the cable (which should make the object/lights of the screen disappear momentarly). Then plug it in again, now the object should light up the computer screen again, obviously. However Now when the player clicks "look at screen" (All this is happening in the same room, to be clear!) it should instead show a login screen where the player needs to type a correct password. That password should be found in another room, but if the player knows the password before, there should be no need to find out the password in the other room. I hope that was a clear explanation of the puzzle i'm trying to create :)
Sure. So:
-A different room for the computer screen is fine, that's a perfectly normal way to do it.
-When you unplug and replug the computer, you could make an object visible with the new screen state. Clicking that object could potentially bring you to another "computer screen" room.
-However, as an alternative you could use a global variable as you say, and use the same "computer screen" room and display different things on the screen depending on that variable.
-If the password isn't an inventory item, you probably do need a global variable to keep track of whether the player has it. You can create one called "knowsPassword" of type bool. Then to check whether the player knows the password you write something like:
if(knowsPassword)
{
// TODO: Log in to the computer
}
else
{
// TODO: Say something like "Looks like a need a password"
}
Then in the other room, if the player learns the password you just write:
knowsPassword = true;
Quote3. E-block is confusing to me, a lot of people seems to use it on youtube. I was hoping what it does is make the animation none canceable, is that correct? So forexample when me and my friend plays point and click games, many times in dialogs we accidently hit a mouse button and it skips. I want that to NOT be able to happen, at least the first time you hear a dialog, then perhaps you could be able to skip it if it repeats. How would you go on about creating that?
eBlock and eNoBlock are alternative ways to run animations and some other actions (the e at the beginning just means that they're "enum" values: a fixed list of options to choose between – in this case block or no-block). The difference is whether the rest of the script "blocks" or not: blocking basically means that it pauses, waiting for the command to finish before it continues on to the next line. When the game is blocked, most interaction is disabled.
Blocking is the easiest way to have a bunch of things happening in order (which is often called queuing actions). (Speech, for example, is blocking: A character says one line, and the game waits for that line to finish before the next line.)
Speech can be skipped by a key or mousebutton press (depending on your settings), but many blocking commands cannot be interrupted. So to do what you describe with making actions cancellable, they usually need to be non-blocking. However, queuing actions becomes much more difficult that way, so as a newbie I probably wouldn't attempt it.
Thanks so much for your thoughtful explanation! Well i have a lot of questions. I can already see you guys saying to yourself "read the manual". Well i'm trying too! the scripting part is easy to understand in the beginnings but like i've said it's a bit of chinese once he starts to name different += -= and what it does only in "values" not in examples, which would have been more helpful. For someone who have never done anything like this before. Is there anything i should read before reading about the scripting to make me understand it better, if you know what i mean? The parts before scripting i already understood
Forexample "go to this webpage and read about basic programming for this and that, that will clear out things, how to set variable, when to use a += versus -= etc etc!".
I think that's very unclear since he is not giving real life examples just saying what happens to the numbers. It's not "clicking" in my brain, how should i know what happens to those numbers if no example is given except for one instance, where the character says 3 different lines and then repeats the last one. I managed to get it to different outcomes by using -= and += or raising the number, etc, but i didn't "see the logic". If that makes any sense? Like when should i have used += instead of just ==0 which was in the example, in what example would that be more viable? It makes no sense to me. Unfortunaly the answer you gave is still over the top of my head. I don't know "abc" yet. All i know is how to display a message when the player does something, or perhaps looks at something and say something either player/cego or "display", how to pick something up, make the object go into the inventory and disappear on the screen. That's the only things i've learnt from the manual and youtube so far. Thanks ever so much again both of you guys replied quicker then i would ever have imagined! (laugh)
I'll let someone else recommend a good intro to programming site, but as for += and -=, they're just shorthard for a = a + b and a = a - b, respectively.
So if you have:
int a = 1;
a = a + 2; // a = 1 + 2, so now a is 3
You can write it instead as:
int a = 1;
a += 2; // now a is 3
And same with -=
==, on the other hand, is very different. That's a comparison operator, and the result it gives is true (if the values on each side are equal) or false (if they're not). True and false are the so-called boolean values, represented by the data type bool. So you can have:
bool isItTrue;
int a = 10;
a -= 3; // a = 10 - 3, so a is 7
isItTrue = (a == 7); // We're setting the value of isItTrue to the outcome of the equality-comparison of a and 7. Since they're equal, it's true
== is mainly used in conditions, like this:
if(a == 0)
{
// Do a thing
}
Thanks again! I think i will Pm you after i've "bruteforced" my way thru something semi-working.
Cause i doubt i will get a multipuzzle working with this little knowledge.
It's better to ask on the forums, so others can both step in with help and benefit from any help given.
Ofc, but it's a little bit embarassing to have to ask for code 75% of the time! (laugh)
I'm on my way now tho! :)
Just take your time, don't rush, keep things simple...
It will fall into place as you progress through reading the help file, searching the forums and your dedication... ;)
And never worry about asking questions.... a question at a time..
Yeah, try, experiment, read the manual, search the forum for your doubt... and if all else fail, ask!
We love to help... but we also like to see that people at least tried to solve the problem first on ones own. ;)
Quote from: Slasher on Fri 22/02/2019 19:30:18
Just take your time, don't rush, keep things simple...
It will fall into place as you progress through reading the help file, searching the forums and your dedication... ;)
And never worry about asking questions.... a question at a time..
I'm not so sure about that, but it's nice to hear someone believing! :)
At least i've got the how to toogle images on/off going on now comfortably, so i feel pretty comfortable with the "basic" stuff.
It's when it get's into these type of things "if" and "if else", global variables that i struggle. Well well, i probably have some weeks on me to figure this stuff out, the friend is sick so he won't show up in a while, but it will be a fun surprise even if i don't make it on time, for sure.
Have some funny dialogs since we both are in the game. He get's to hang in my entire apartment "in game", open the toilette, working on making it flush:able for shit on the floor in the entrance, and open the washing machine (laugh)
But don't worry. It's a little bit of a joke now, but i will probably try to make this more serious later. Cause it's so much fun! :)
Quote from: Cassiebsg on Fri 22/02/2019 19:36:50
Yeah, try, experiment, read the manual, search the forum for your doubt... and if all else fail, ask!
We love to help... but we also like to see that people at least tried to solve the problem first on ones own. ;)
Believe me, i'm hitting that search button like crazy! :-[
Edit: Amateurs like me. If you type something and it doesn't work hit that f1 button. HUGE help! Mark the word or have the mousepointer by in a word you dont understand and it goes directly to that section in the manual. HUGE help. Helped me a lot so far. Forexample in less then half a minute i've learned how to turn off the main Gui.controls momentarly for my computer error puzzle, so good!
Edit again: Got crazy, it isn't as simple as just "switch to another hotspot", if hotspots are at the same place in the same room one will get erased. So instead you have to use a object. Forexample in my case, i had three different objects i think it was for the damn screen to turn on (not working but on), turn off (say something "ohh its off now)" and on (ohh now it works *goes onto login page*)". Hopefully n00bs can catch that.
Probably is somewhere in the manual, but ofc i missed that part.
:-D (laugh)
Quote from: Olleh19 on Fri 22/02/2019 20:02:20
For example in my case, i had three different objects i think it was for the damn screen to turn on (not working but on), turn off (say something "ohh its off now)" and on (ohh now it works *goes onto login page*)".
That doesn't sound like you need three objects. Why not use one object and change it's sprite according to the screen's state? Or are you talking about the on/off-button? If it's just about what the player responds, one hotspot (or object or GUI) is enough, you just have to change what the player says (using a variable).
function cmdbox_OnActivate(GUIControl *control)
{cmdbox.Visible = false;
Wait(1);
Parser.ParseText (cmdbox.Text);
String badword = Parser.SaidUnknownWord();
if (badword !=null) player.Say ("'%s'. Wrong password", badword); player.Changeroom(10);
else if (Parser.Said("theonlywordihaveintextparser")) player.Say("Bra jobbat!"); player.ChangeRoom (2);
I hope you guys understand what it is i am trying to achieve. If "right" password is typed he should go to another room, but if wrong password, back to the room where the screen is in. But unfortunaly it does not work that way (it seems).
Matti, i am a complete beginner at this. I made it work with my "diy" solution. There are most likely more efficient ways.
Why i changed between three pictures was because the player was going to say and interact different things on each and everyone and they were at the exact same spot (a computerscreen).
Which by the way also made the hotspots flip out, if i was browsing the last sprite that i added, it changed to the first sprite (hotspot id) that was placed at the same place, what i did is basically stack a layer on top of eachother and made them enabled/ or disabled. Again, most likely i'm doing it "wrong" why the program worked against me, but i solved it by manually typing in x/y of the other pictures that i layered on top.
Edit: Managed to get it to change room when right password is typed but i still want the message to be displayed "yes, thats the right password", or when answering wrong password, wrong and = back to the computerroom.
Here we get to one of my often-insisted-on topics: code formatting.
The compiler doesn't really care how you format your code, but for humans it's important in order to make it readable. Newbies often underestimate how important this is. If your code is badly formatted, you can easily confuse yourself about what it does. So let's take your snippet above and format it "correctly" (meaning, according to common convention)...
function cmdbox_OnActivate(GUIControl *control)
{
cmdbox.Visible = false;
Wait(1);
Parser.ParseText(cmdbox.Text);
String badword = Parser.SaidUnknownWord();
if (badword !=null)
player.Say("'%s'. Wrong password", badword);
player.Changeroom(10);
else if (Parser.Said("theonlywordihaveintextparser"))
player.Say("Bra jobbat!");
player.ChangeRoom(2);
// ... More code here? Without the closing bracket, the function seems incomplete
}
You see that some things become immediately apparent with this formatting â€" notably, that the "if" and "else" conditions only apply to the next following statement. You can't make it apply to multiple statements just by putting them on the same line (like I said, the compiler doesn't care about the formatting). If you want to make multiple lines all conditional on one statement, you have to use curly brackets { }:
function cmdbox_OnActivate(GUIControl *control)
{
cmdbox.Visible = false;
Wait(1);
Parser.ParseText(cmdbox.Text);
String badword = Parser.SaidUnknownWord();
if (badword !=null)
{
player.Say("'%s'. Wrong password", badword);
player.Changeroom(10);
}
else if (Parser.Said("theonlywordihaveintextparser"))
{
player.Say("Bra jobbat!");
player.ChangeRoom(2);
}
// ...
}
The basic rules for code formatting you should follow include:
-One statement per line
-Curly brackets { } on a separate line
-We indent one tab-level (=two spaces) when we're inside a "block of code" (typically: between curly brackets), or a single line after an if-condition or similar
-No space between the function name and the parenthesis, so "Parser.ParseText(cmdbox.Text)", not "Parser.ParseText (cmdbox.Text)"
(You will see some people who put a single statement after an if-condition on the same line and some other variations, but I don't recommend it for newbies. This way is clearer and more consistent.)
Quote from: Snarky on Sun 24/02/2019 08:30:45
Here we get to one of my often-insisted-on topics: code formatting.
The compiler doesn't really care how you format your code, but for humans it's important in order to make it readable. Newbies often underestimate how important this is. If your code is badly formatted, you can easily confuse yourself about what it does. So let's take your snippet above and format it "correctly" (meaning, according to common convention)...
function cmdbox_OnActivate(GUIControl *control)
{
cmdbox.Visible = false;
Wait(1);
Parser.ParseText(cmdbox.Text);
String badword = Parser.SaidUnknownWord();
if (badword !=null)
player.Say("'%s'. Wrong password", badword);
player.Changeroom(10);
else if (Parser.Said("theonlywordihaveintextparser"))
player.Say("Bra jobbat!");
player.ChangeRoom(2);
// ... More code here? Without the closing bracket, the function seems incomplete
}
You see that some things become immediately apparent with this formatting â€" notably, that the "if" and "else" conditions only apply to the next following statement. You can't make it apply to multiple statements just by putting them on the same line (like I said, the compiler doesn't care about the formatting). If you want to make multiple lines all conditional on one statement, you have to use curly brackets { }:
function cmdbox_OnActivate(GUIControl *control)
{
cmdbox.Visible = false;
Wait(1);
Parser.ParseText(cmdbox.Text);
String badword = Parser.SaidUnknownWord();
if (badword !=null)
{
player.Say("'%s'. Wrong password", badword);
player.Changeroom(10);
}
else if (Parser.Said("theonlywordihaveintextparser"))
{
player.Say("Bra jobbat!");
player.ChangeRoom(2);
}
// ...
}
The basic rules for code formatting you should follow include:
-One statement per line
-Curly brackets { } on a separate line
-We indent one tab-level (=two spaces) when we're inside a "block of code" (typically: between curly brackets), or a single line after an if-condition or similar
-No space between the function name and the parenthesis, so "Parser.ParseText(cmdbox.Text)", not "Parser.ParseText (cmdbox.Text)"
(You will see some people who put a single statement after an if-condition on the same line and some other variations, but I don't recommend it for newbies. This way is clearer and more consistent.)
Exactly what i needed to understand, thanks ever so much!
I have experimented with ( ) and (") but i have managed to forget the curly brackets for the different lines :-[ Makes more sense now.
Can't believe the puzzle actually works right now, so cool! :)
Olleh19
You do not need to quote the whole post...
Quote
Olleh19
testing, :-[
Edit: Ahh, got it right! had to leave out your old quote it seems
Hello again! This time i have a question about a sorta like a "on off" thing going on when using the Use button or any interaction button i guess for that matter, push, pull etc, twice on an object animation. I've been looking in the manual again ofc. But it's not clear as for what to use i think for a certain objects animation. I have this machine that is lighten up, but now i want to turn it off when pushing the use button again so the animation should obviously stop, but at a specific frame. But since it's 16 frames of animation, i can't just type "object.stopanimation();", it needs to stop on the right frame (i believe for it too look "smooth" or more nice.)
How would i accomplish that with code?
Perhaps it works with the "if bla bla, or else turn off the animation?) type of commands. Still haven't gotten my head around those type of commands. I just copy paste the thumbleweed preset in the script starts :-[
Thanks again guys for your help so far, hopefully soon a playable demo should be available, if anyone wants to play! (laugh)
So you have a looping animation running that's been set with myObject.Animate(loop,delay,eRepeat); ?
If the frame you want to stop on is either the last or the first frame in the animation, I think you can just write:
myObject.Animate(myObject.Loop,delay,eOnce); // Use 2 instead of eOnce to stop at the first frame
I think this will override the current animation, leaving it on the current loop and frame, then start running a new animation from that loop and frame that stops at the last frame. If this doesn't work, try adding myObject.StopAnimating(); right above it and see if that helps.
If it doesn't work (for example because Object.Animate() always starts from the first frame in the animation loop) you will have to do something more complicated.
function oAbmachine_Interact()
{
player.Walk (210, 130, eBlock);
player.Say ("bla bla bla!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eNoBlock);
}
Edit: My last attempt for tonight/early morning going to bed now. Still not working.
function oAbmachine_Interact()
{if (Verbs.UsedAction(eGA_Use))
{
player.Walk (210, 130, eBlock);
player.Say ("Yeah, let's try that!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eBlock);
}
else if(Verbs.UsedAction(eGA_Use))
{
ifabmachineisinuse = true;
oAbmachine.StopAnimating();
}
I'm not sure you understand what i'm trying to do. It should be an endless loop of light until i sorta like a radio or a tv that can be turned on and off when clicked on it (so the animation obviously should stop, or change to another animation)?
I added the stopanimating(); line but it didn't help, in fact it made the animation not work at all. I'm thinking perhaps i'm doing this in the wrong events tab?
This is so common in point and click games would be surprised if it's really difficult to do! 8-0
I'm clicking on the object/interact with object, or should one create a hotspot for this? I'm a bit confused when to use a hotspot and when not to.
Quote from: Olleh19 on Wed 27/02/2019 00:34:40
I'm clicking on the object/interact with object, or should one create a hotspot for this? I'm a bit confused when to use a hotspot and when not to.
In point-and-click adventure games, you obviously want some stuff in the room to be "clickable", and (depending on your UI â€" it looks like you're using Tumbleweed Verbs) to display its name when you hover the mouse over it. In AGS, characters and objects are clickable by default (though you can turn it off on a case-by-case basis). But what if the thing you want to be clickable is just some part of the background? That's when you use hotspots. It lets you mark a part of the background as a clickable region and give it a name, without having to add an object or character. Typically you'll use it on stuff that you can't take or that doesn't move, e.g. for a window that you can just look out of, or a bookshelf with stuff you can't take. If you have a clickable object or character, you don't need it.
In this case, if I understand you correctly, you have an object that should
start animating (and let you do other things) when you click on it once, and
stop when you click on it again. Your first piece of code looks fine for starting it.
The next thing we need to do is figure out how we know whether to start or stop when we click. Actually, the next thing we need to do is
format our code correctly, remember (https://www.adventuregamestudio.co.uk/forums/index.php?topic=56946.msg636602227#msg636602227)? Let's take the code you have and reformat it:
function oAbmachine_Interact()
{
if (Verbs.UsedAction(eGA_Use))
{
player.Walk (210, 130, eBlock);
player.Say ("Yeah, let's try that!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eBlock);
}
else if(Verbs.UsedAction(eGA_Use))
{
ifabmachineisinuse = true;
oAbmachine.StopAnimating();
}
} // This last bracket was missing, which becomes obvious once the code is correctly formatted
You have half of a correct idea here: You do want two code-blocks inside the function, one to start and one to stop. However, what you put in the if-condition has to be the thing that tells you which action to take, and in this case that's "is the machine running?", not "did I click on it with the 'Use' interaction?".
So, given that you're using Tumbleweed Verbs, the code should be structured something like this:
function oAbmachine_Interact()
{
if (Verbs.UsedAction(eGA_Use)) // Clicked "Use"
{
// Always walk up to the machine
player.Walk (210, 130, eBlock);
if( THE MACHINE IS NOT RUNNING )
{
// Start the machine
player.Say ("Yeah, let's try that!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eNoBlock); // You had this set to eBlock, which would stop you from doing anything else after you started it
}
else // The machine *is* running
{
// TODO: Stop the machine
}
}
// Here come the other verbs
else if(Verbs.UsedAction(eGA_Look)) // Clicked "Look"
{
// Look
}
// Other verbs...
}
So how do we know whether the machine is on or off? I see you've created a variable called "ifabmachineisinuse", which is one valid approach, but (1) you're only setting it, not using it in the if-condition to determine what to do, and (2) you're (trying to) set it to true when you turn the machine
off, while it ought to be set to true when you turn the machine
on, and false when you turn it off. Let's fix that:
bool abMachineIsInUse=false;
function oAbmachine_Interact()
{
if (Verbs.UsedAction(eGA_Use)) // Clicked "Use"
{
// Always walk up to the machine
player.Walk (210, 130, eBlock);
if(abMachineIsInUse == false)
{
// Start the machine
player.Say ("Yeah, let's try that!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eNoBlock);
abMachineIsInUse = true;
}
else // The machine *is* running
{
// TODO: Stop the machine
abMachineIsInUse = false;
}
}
// The other verbs ...
}
Note that I changed the variable name from
ifabmachineisinuse to
abMachineIsInUse, for two reasons: (1) It doesn't make sense to have "if" in this name, because then when you use it in an if-condition it becomes doubled-up:
if (ifabmachineisinuse == false). (2) I use a capital letter at the start of each new word in the name, apart from the first one (this is called "CamelCase"). You should get in the habit of always marking the word-divisions in your variable names: it makes things much more readable (if I just glance at your version, I might see the string "chineisi" in the middle and wonder if there's something Chinese going on), and otherwise you'll sooner or later run into the "expertsexchange.com" problem of ambiguous names. You can use CamelCase or underscore_naming to break up the words in the name.
I point this out because giving good variable names is another really important "soft" programming skill that I think people neglect far too often.
OK, so now that we have the code structure set up, let's try my suggestion:
Quote from: Snarky on Tue 26/02/2019 22:58:03
If the frame you want to stop on is either the last or the first frame in the animation, I think you can just write:
myObject.Animate(myObject.Loop,delay,eOnce); // Use 2 instead of eOnce to stop at the first frame
So:
bool abMachineIsInUse=false;
function oAbmachine_Interact()
{
if (Verbs.UsedAction(eGA_Use)) // Clicked "Use"
{
// Always walk up to the machine
player.Walk (210, 130, eBlock);
if(abMachineIsInUse == false)
{
// Start the machine
player.Say ("Yeah, let's try that!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eNoBlock);
abMachineIsInUse = true;
}
else // The machine *is* running
{
// Stop the machine
oAbmachine.Animate(myObject.Loop, 2, eOnce, eBlock); // We're interrupting the eRepeat animation and just running an eOnce animation
abMachineIsInUse = false;
}
}
// The other verbs ...
}
So, now the question is, does this work to "smoothly" stop the animation?
Was up till 4am this night trying to get it to work, my copy-paste failed leaving one bracket out. What i meant to say was that the code was "working" (the one i pasted) but the end result still wasn't that the machine "turned on/off" so to speak.
With your modifications and great explanations it now works.
It works perfectly fine now! God, i thought i've learn't how to format the code. I need to look more closely at your examples again.
Thanks so much again!
Cool, glad you got it working!
A couple of other tips:
1. If you want the dialog to be different the first time you start the machine vs. other times, you can use Game.DoOnceOnly():
if(abMachineIsInUse == false)
{
//Start the machine
if(Game.DoOnceOnly("start abMachine"))
player.Say("Yeah, let's try that!");
else
player.Say("Let's try again!");
oAbmachine.SetView(9);
oAbmachine.Animate(0, 2, eRepeat, eNoBlock);
abMachineIsInUse = true;
}
2. I think one reason why you were having trouble here is that you were trying to do too much at once. In programming, it's very helpful to divide up problems into small tasks, and focus on solving one thing at a time: otherwise you often end up with a bunch of complicated code and no idea why it doesn't work. Here you were trying to figure out two things you didn't know at the same time:
-how to stop an animation "smoothly" (run until it reaches a certain frame)
-how to toggle something on and off so that it turns on when you click it once and back off when you click it again
If you'd focused on solving each problem separately, you could have reduced the complexity a lot on each task, and then once you figured it out you could just have combined the two solutions. I think it would have been a lot easier.
One way to do that is to use placeholders for "stuff goes here", like I did above when I put "TODO: Stop the machine". If you're trying to test that the overall logic of toggling the switch is correct, I'd put a placeholder you can see when you run the game, just a very simple command like Display("The machine turns off");. Then when you know that it runs when it's supposed to, you can add the actual code.
ignore
Good to know! I'm beginning to get beyond frustrated by the Manual tbh. I'm again just sitting here and guessing what "might work", and obviously it don't. My programming career would have ended long ago, if it wasn't for your help, Snarky! V E R Y Thankful. It seems like the character now disappears slightly when walking by the Machine, so what i immediately think about, is that the object probably is like characters set to "solid".
Searching in the manual and looking at "object.solid" it should indeed be available for objects aswell. So i pick "events after or before entering the room" (Again, just guessing, nowhere to be found in the manual which events tab i should choose for the object other then "common sense". Makes more sense that the object is solid = false; before the actual "interaction" starts, right?! so i added myobject.solid = false;
And ofc, the command seems to run thru but it doesn't do anything, character still get's invisible when passing thru parts of the object. Then in the manual it says before anything it looks like i should have typed an "bool machine.Solid" command? So i try that in the script beginning what happens then.
Well then i get this failure "oAbmachine is already imported". Which also doesn't make sense to me. I used the "oAbmachine" many times in the script. There is a bool set but it's not called oAbmachine. Why won't AGS let me? :confused:
:cry:
The .solid property probably isn't quite what you're looking for. It controls whether you can
walk through something or must walk around it, not whether you can
see through it.
As long as an object is visible, it's going to cover up anything that is behind it. So it sounds like your problem is that AGS thinks your character is behind the object when actually it's in front of it.
The order in which things are in front of or behind each other are controlled by the baselines. A character's baseline is at its feet (by default), and the rule is that anything with a baseline that is higher up on the screen (smaller Y-coordinate) is behind anything with a baseline lower down. This tends to work out correctly when everything stands on a floor seen from above, but sometimes the baselines will be off, so it is possible to overrule them (in the editor or in scripts).
Quote from: Olleh19 on Wed 27/02/2019 13:29:35Then in the manual it says before anything it looks like i should have typed an "bool machine.Solid" command? So i try that in the script beginning what happens then.
Where are you seeing that? That doesn't really make sense.
Quote from: Olleh19 on Wed 27/02/2019 13:29:35Well then i get this failure "oAbmachine is already imported". Which also doesn't make sense to me. I used the "oAbmachine" many times in the script. There is a bool set but it's not called oAbmachine. Why won't AGS let me? :confused:
TBH I can't quite follow your explanation about what you've done or why. If you want help on specific errors in your script, you'll need to copy the exact content, otherwise we can only guess.
QuoteWhere are you seeing that? That doesn't really make sense.
from the Manual (Again, remember i am Swedish, maybe i am just reading this "wrong"):
MANUAL : "Solid property (object)
bool Object.Solid
Gets/sets whether the object can be walked through by characters.
If this is set to true, then the object is solid and will block the path of solid characters. If this is set to false, then the object can be walked through by characters.
NOTE: solid objects only block characters, they don't block other objects from moving through them.
Example:
oSmallrock.Solid = true;
will mean that the Smallrock object blocks the path of characters."
I have used forexample with the computer screen similar actions with success. hScreen.Enabled = false; or oOffscreen.Visible = false;
But most likely those commands would not work. I cannot make the object disappear then the function's that you helped me with will not function probably cause the object is not visible by then (i think?). I could easily solve this in the future by just making the object smaller, it's the entire machine, i could just crop the image to only be around the blinking light, that would solve things, so if there is no "easy way out" i will have to do so, i suppose.
my code was this,
function room_Load()
{
oAbmachine.Solid = false; //Shouldn't this make the player be able to just walk over the object without "dissapearing"? That's the command i'm looking for!
}
EDIT: AAAAAAAAH!! I get it now. Walkthrough in this case just means being able to walk onto it. That has nothing to do with weither the character/objects appearance.
EDIT: A picture says more then 1000 words. Perhaps there is some kind of "layer function" similar to photoshop where i can choose the character to go over all the other objects?
[imgzoom]https://i.imgur.com/f21mILa.png[/imgzoom]
Am i pushing wrong all the time? I pushed MODIFY not Quote. Still i get a new post once again. Sorry. Just have Modify, Quoting should be inside the text editing (i think) OR on someone elses text. I hope admin don't mind taking that change into consideration. :smiley:
I think on other forums there is not an option for Quote so i accidently click it everytime i should edit my post :-[
You clicked "quote" by accident. Clicking "modify" leads to a textarea containing just the post, without [quote] tags around it, and has a "Save" button below, instead of "Post".
As for the manual's
bool Object.Solid
This means that each Object has a .Solid property of type bool, which means you can set it to either true or false.
When you used bool oAbmachine AGS thought you wanted to declare a bool variable called oAbmachine, and informed you that this variable already exists.
As for "events after or before entering the room", please read what it actually says.
The events are called "Enters room after fade-in" and "Enters room before fade-in".
"before fade-in" is where you set up room-specific stuff while the screen is still black (like positioning characters for a cutscene); "after fade-in" is where you put stuff that's supposed to happen as soon as the room is fully visible (like making them walk somewhere).
In general, if you have difficulty understanding the manual, keep in mind that you are learning how to program and how AGS's API works at the same time. The manual assumes basic scripting knowledge, so can be difficult for a beginner programmer to make sense of. That's not the manual's fault though.
Quote
You clicked "quote" by accident. Clicking "modify" leads to a textarea containing just the post, without [quote] tags around it, and has a "Save" button below, instead of "Post".
Ah, yeah makes sense. I have to get used to it. Since my programming knowledge is lacking a aweful lot. I don't know if you have read any of my wall of texts so far, but i actually did ask about advice on where to learn "basic coding" since i just like you pointed out feels like ags manual expects you to "know" programming beforehand, which i don't. But it's funny when it starts to work, and you guys are a HUGE help. I also read things wrong cause of my english reading ability isn't up to par.
QuoteAs for the manual's
bool Object.Solid
This means that each Object has a .Solid property of type bool, which means you can set it to either true or false.
When you used bool oAbmachine AGS thought you wanted to declare a bool variable called oAbmachine, and informed you that this variable already exists.
Ahh, that clarifies that situation!
QuoteAs for "events after or before entering the room", please read what it actually says.
The events are called "Enters room after fade-in" and "Enters room before fade-in".
"before fade-in" is where you set up room-specific stuff while the screen is still black (like positioning characters for a cutscene); "after fade-in" is where you put stuff that's supposed to happen as soon as the room is fully visible (like making them walk somewhere).
Yes, yes ofc i get that. I was just getting frustrated when none of the options seems to do anything. But it was because i "read wrong". Walk through a path is different then "walking thru an object". Which my mind was reading. Probably cause English is not my native language, again................ :-X
QuoteIn general, if you have difficulty understanding the manual, keep in mind that you are learning how to program and how AGS's API works at the same time. The manual assumes basic scripting knowledge, so can be difficult for a beginner programmer to make sense of. That's not the manual's fault though.
If you could be so kindly please direct me to some webpage where i can learn more about such basic concepts. Because i don't want to be a pain in here. I already feel like guys in here get annoyed cause i keep asking "stupid questions". Even tho it's a beginners forum. I did solve a lot of things myself which i clearly showed in various examples. But it would be good to know what i should "look for". What's relevant programming basics for AGS.
Unfortunately there's not really a single good entry point to learning the programming skills you need to use AGS. You'll need to a basic grounding in (imperative) programming concepts, and you'll also need basic knowledge of some of the common programming terms, constructs and syntax used by AGS script.
AGS Script belongs to a family of programming languages that are all written in pretty much the same way, with many of the same conventions and keywords: C-like languages (https://en.wikipedia.org/wiki/List_of_C-family_programming_languages). Popular C-like languages include C, C++, Java, C#, Objective-C, and PHP (JavaScript is a language that borrows a lot of the "look and feel" of C-like languages but actually behaves quite differently). If you learn how to read and use any of these languages, you should be able to understand almost any AGS code.
The language that AGS Script most closely resembles for everyday use is probably C, but it also borrows some things from Java and C# (notably the way Strings work is more like those languages; and also the fact that a lot of the AGS code is event-driven). So I would recommend that you find some good "intro to programming C" tutorial to help you get your bearings.
Quote from: Snarky on Wed 27/02/2019 15:55:30
Unfortunately there's not really a single good entry point to learning the programming skills you need to use AGS. You'll need to a basic grounding in (imperative) programming concepts, and you'll also need basic knowledge of some of the common programming terms, constructs and syntax used by AGS script.
AGS Script belongs to a family of programming languages that are all written in pretty much the same way, with many of the same conventions and keywords: C-like languages (https://en.wikipedia.org/wiki/List_of_C-family_programming_languages). Popular C-like languages include C, C++, Java, C#, Objective-C, and PHP (JavaScript is a language that borrows a lot of the "look and feel" of C-like languages but actually behaves quite differently). If you learn how to read and use any of these languages, you should be able to understand almost any AGS code.
The language that AGS Script most closely resembles for everyday use is probably C, but it also borrows some things from Java and C# (notably the way Strings work is more like those languages; and also the fact that a lot of the AGS code is event-driven). So I would recommend that you find some good "intro to programming C" tutorial to help you get your bearings.
Thanks Snarky, you have been very helpful!
You can forget about those other questions. I was just feeling a little bit of frustration. I had similar issues with the bakgrounds in the beginning. Just because the resolution is 320/200 doesn't mean the image is to be drawn that size, i learnt that "the hard way", you have Gui's and maybe other things in the way. I see it the same way with the object. Next time i'll draw the object in the exact little size for it to be clickable and not any bigger then needed for it to work, so the character won't need to cross it's pixels in any way.