So after a friend told me to bite the bullet and actually try coding in AGS, as opposed to hoping someone would offer to do it. I fired up a newly downloaded copy, grabbed all my game graphics and spent today getting to work on learning coding.
6 hours later and I have a room, a custom-ish GUI and 48 lines of code covering all the basic look at and an inventory item.
I have an entirely new found respect for code monkeys.
Anyway, onto my questions:
-Is there any way to change the colour and font of the standard text box that appears when display("text") is called? It's defaulted White and black.
-Is there any way to change the quit game GUI? I can't seem to locate it, the grey jars with just about everything.
-Is there an easier way to do conditional branches without having to type out:
function hbookshelf_Interact()
{
if (player.HasInventory(iDIY)) {
cEgo.Say("I don't think I'll need the rest");
cEgo.Say("Though I am curious as to how they filled four-hundred pages");
cEgo.Say("with 'The Art of Bed-Making'");
}
else {
cEgo.Walk(125, 144, eBlock);
cEgo.FaceLocation(125, 150, eBlock);
cEgo.Say("You never know when a book on DIY is going to come in handy");
cEgo.AddInventory(iDIY);
}
}
Lastly, how do I create an @OVERHOTSPOT@ style line for the action the player is hovering over on the GUI? Preferably hovering next to the cursor in a box.
Thanks in advance.
1) Right click to make a new Gui, but select 'New Text Window GUI'. Then go to General Options and 'Custom text-window GUI' to the number of the Gui you just made. [Edit2]: Check out 'Customized Text Windows' in the manual for more details.
2) You'd have to make your own, but I'd suggest looking at the Restart Gui that's included in the default template. Then, use the QuitGame(0) (just so you know, passing a 1 pops up the Gui that you want to change, whereas a 0 just quits automatically)
3) Nope. if and else is all you got. There's requests for switch statements, but you wouldn't know what those are anyways.
4) Multiple ways to do this, but you'll want to check out 'GUIControl.GetAtScreenXY' in the manual.
[Edit]: Couple of extra things:
-I may come back and post some code for #4, but I kinda wanna make you try it out and then post for help (if needed)
-Did you know that you can use player.Say("blah") instead of cEgo.Say("blah") (assuming that cEgo is set as the player character)
~Trent
Plus, keep in mind that if the player is able to loose the DIY book in the vicinity, he'll be able to pick it up again and again and again.
Regarding 4:
Put a label (lAction) on a GUI (gAction), then in repeatedly_execute, call this:
void UpdateAction() {
String v;
if (mouse.Mode == eModeInteract) v = "Interact with";
...
v = String.Format("%s @OVERHOTSPOT@", v); // add hotspot name to end
lAction.Text = v;
int w = GetTextWidth(v, lAction.Font) + 2; // +2 to compensate for wrong value if it's outlined text
lAction.Width = w;
gAction.Width = w;
int x = mouse.x + 2;
if (x > 320-w) x = 320-w; // replace 320 with actual screen width
int y = mouse.y +2;
if (y > 240-gAction.Height) y = 240-gAction.Height; // some for 240
gAction.SetPosition(x, y);
}
The label should be put at 0;0 on the GUI and both should have the proper height for the used font.
Thanks for all the help guys, I could get 4 working, both trying it myself and using the given code. But that's not big issue at the moment.
Another issue has arisen. Is it possible to have a script that runs everytime an undefined interaction is executed.
For instance, if I use the DIY book on the window in my room, I don't want the character to walk over there and do nothing. Is there a way I can set a script to recognise an unfilled function and replace it with some text. I know the movement thing is as simple as turning off the "Always walk to hotspot" thing.
Erm, simpler terms. The players uses the book on the window, I want a message that says something like "i don't think that'll work" display. But I want it to display for every false interaction.
No, in the events for the window you have define what you want it to display and when the character does what event.
Huh? Please don't give advice until you've figured out the basics, Swordwielder.
Cluey:
Look up UnhandledEvent() here:
http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm
Ah brilliant!
Thanks a bunch.
I am totally new to the inner workings of AGS, I just want to get a demo made and then get a REAL programmer on board.