Hello,
I downloaded AGS, started with the tutorials and manual, so you know that if I bother you guys with my questions, it's because I've been searching amongst the forums,manual,tutorials I could find without finding an answer to my problems.
I'm not much of a scripting guy, I think I get the "logic" of it, I understand "if","else" and other stuff so far, but there are a lot of things that my mind don't really get... right now ::)
When I read the forums, you guys explain things to one another as if everyone knows what it is all about, but for me it's like reading a foreign language.. ???
The other thing is that many forum topics and other scripting tutorials seem to be outdated due to the new version, our with a broken link, also...
So I don't want to take too much of your time; I know you have other things to do... I just need a little (clear) push here and there, and I'll sort the rest out myself. ;)
I'll keep all my annoying question in this topic.
Please keep in mind I'm not a scripter.. yet... so please use a language I understand :-[
Well here goes my first little problem:
1/ - I create a global variable named "health" as "int" and give it "10" points.
- In the room, I put "Health +=1;" and I get "Parse error unexpected 'Health'"
- So I try "import Health;" and I get "Expected variable or function after import, not health"
- So I try "import int Health;" and I get "Variable 'Health' is already defined"
2/ - I want this variable to be shown in the GUI. Believe me I've been searching and testing around for hours.
- I tried text boxes, labels, globalints and whatever , tried to understand how the @score@ can work if it's not looking for a variable names score,
wich I can find nowhere, I thought @variable@ would just display the value of that variable in the gui ...?
- The only thing I found was to create a button that, when you click on it, would display that variable, but that's not what I want.
Well, any help would be greatly appreciated and thanks in advance for your precious time!
;D Rik
1. Make sure the variable is always written the same way. Sometimes you wrote health, sometimes Health. Capital letters DO matter.
2. Create a Label and write the following to update the shown variable:
Labelname.Text = String.Format("%d", Variablename);
Labelname is the name of your label and Variablename the name of your variable, obviously.
Hey Rik, with this attitude you can look forward to lots of capable guys eager to help you :)
1. Capitalization is important. You need to use the exact name in the script that you used in the global variables pane.
Usually, after having typed the first three letters of something known to AGS, the auto-complete window should kick in; if it doesn't you're probably doing something wrong.
Where exactly did you put the line? Because, like everything else (except declarations, e.g. "int a = 1;") it has to be inside a function. Which function that is is determined by when you want the command to be called.
If you want stuff to happen right when the first room is loaded/displayed, choose one of the room's "player enters room" events, click on it, then click the ellipses button. The function is then added to the room script and linked to the event:
function room_Load() //*
{ //*
health+=1;
} //*
*created by AGS
2. see above :)
Aha! Of course that script in 1. doesn't work properly.
You only changed the script header, where you wrote the "import"-script.
You also have to change the line in the Global script from int health; to int Health; .
NsMn, please don't confuse people unless you at least know what the problem is.
Thank you very much guys! Had to think a little what you were talking about, but I got it ;D
I was like "Damn Mr Matti don't just tell me what I have to type, tell me also where!" but after testing some things I found it.
:)
So now I have this in the globalscript:
int Health = 10;
export Health;
function repeatedly_execute_always()
{
Label6.Text = String.Format("%d", Health);
}
And this in room 1 and 2:
import int Health;
function room_Load()
{
Health +=1;
}
So every time I enter one of these rooms, I get + 1 health and it's shown where I want! :D
Now one last little question about this:
- Is there a way to avoid typing "import int Health;" in every single room? I've been trying some things, not working, and you cannot import in a function.
Any tips?
Thanks a lot for your help, It's been most productive!
;D Rik
Oh, now I can re-wite my last post a bit ;D
There's also a script called "script header". Put the import-code in there and you don't have to import it in every room.
If you create the Health variable via the global variables pane*, it's accessible in every room without having to import it.
* I think you need AGS 3+ for that, but you should use the newest version anyway..
2 ways:
1) Put the import line in the GlobalScript.ash (Ctrl-H is a keyboard shortcut that jumps straight to it)
OR
2) Delete the declaration line and export line, and create a new variable using the Global Variables Pane (in the tree to the right). Right click, choose 'create new variable', name it, choose int, and set the initial value to 10.
And yes, even if you're new you have a great attitude so we're very willing to help. Welcome to the forums!
~Trent
Or, use the global variables pane to create the variable. Then you won't have to bother with importing/exporting stuff.
(If you want to use a global variable of a type available there though then yes, importing it in GlobalScript.ash is the way to go.)
Wow yay thanks a lot! I made it work correctly with the global variable panel!
Thanks a lot for your time, I made more progress in the last few hours than in the last days lol ! You all are in the game credits already. ;)
Ok... still so much to learn... arr heh!
Thanks again!
;D Rik
Hello, here I am again... well continuing to learn things... The possibilities are amazing and I just LOVE the very clear debug mode that helped me a whole lot of (hard) times! ;D
Now, I just have this little question, didn't find an answer...:
Can I do something so that the room's music continues to play even if I start to play a movie?
...
'cause the movie is cutting the music...
Thanks a lot!
;D Rik
How are you playing the video? I guess this is really 'what format is the video?' - if you're playing it with
PlayVideo (that is, if it's any format but FLI/FLC) then passing 10 or 11 as the third parameter (
flags) should keep game audio
Quote from: TheManual
FLAGS can be one of the following:
0: the video will be played at original size, with AVI audio
1: the video will be stretched to full screen, with appropriate
black borders to maintain its aspect ratio and AVI audio.
10: original size, with game audio continuing (AVI audio muted)
11: stretched to full screen, with game audio continuing (AVI audio muted)
Or have you tried that, and it didn't work? (I haven't used
PlayVideo in v3+, so it might not be as clear cut as the manual makes it seem...)
Quote from: GuyAwesome on Wed 17/06/2009 22:59:02
Or have you tried that, and it didn't work? (I haven't used PlayVideo in v3+, so it might not be as clear cut as the manual makes it seem...)
Damn I'm sorry... :-[ You know, the funny thing is I did read that passage... but somehow... my brain didn't print it... :-[ so many things to learn, to look after, to remember... right now I'm totally lost lol... phew... ;D ::)
Anyway, thanks a lot for the info! ;)
I guess... we can't play both at the same time?...like having the music from the game and also the FX sounds from the movie... ...?
(Right now I use a sound file -extracted from the movie- to start when the movie starts).
;D Rik
So the flags thing does work, as far as playing game sounds goes?
I'm pretty sure it's either/or with the avi sound, unfortunately - but like I said, I've got no experience with it so hopefully there's a way round it. If not, your method sounds like the best compromise.
Quote from: GuyAwesome on Thu 18/06/2009 01:09:51
So the flags thing does work, as far as playing game sounds goes?
I'm pretty sure it's either/or with the avi sound, unfortunately - but like I said, I've got no experience with it so hopefully there's a way round it. If not, your method sounds like the best compromise.
Yup, the flags thing works: When the movie plays all of the game sounds/tracks continue playing. :)
;D Rik