Various Beginner questions regarding scripting

Started by Olleh19, Fri 22/02/2019 13:48:13

Previous topic - Next topic

Olleh19

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.  :-[





Slasher

#1
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

Snarky

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:

Code: ags
  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:

Code: ags
  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.

Olleh19

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!

Olleh19

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:

Code: ags
  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:

Code: ags
  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)




Snarky

#5
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:

Code: ags
  int a = 1;
  a = a + 2; // a = 1 + 2, so now a is 3


You can write it instead as:

Code: ags
  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:

Code: ags
  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:

Code: ags
  if(a == 0)
  {
    // Do a thing
  }

Olleh19

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.

Snarky

It's better to ask on the forums, so others can both step in with help and benefit from any help given.

Olleh19

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!  :)

Slasher

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..

Cassiebsg

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.  ;)
There are those who believe that life here began out there...

Olleh19

#11
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!  :)





Olleh19

#12
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)

Matti

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).

Olleh19

#14
Code: ags
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.


Snarky

#15
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)...

Code: ags
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 { }:

Code: ags
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.)

Olleh19

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)...

Code: ags
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 { }:

Code: ags
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! :)

Slasher

Olleh19

You do not need to quote the whole post...


Olleh19

#18
Quote
Olleh19

testing,  :-[


Edit: Ahh, got it right! had to leave out your old quote it seems

Olleh19

#19
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)

SMF spam blocked by CleanTalk