Changing display text after an event

Started by FamousAdventurer77, Mon 23/05/2011 20:46:08

Previous topic - Next topic

FamousAdventurer77

The wiki didn't answer my question on this as it had to do with changing the name of the hotspot mid-gameplay-- I mean this as in the context of the character knows something/has something.

Ie, you inspect a tree stump where the first Display hints that there's something inside it ("The hollowed out tree stump looks like a good place to hide things.")

So you interact with the stump hotspot to get an inventory item (I like this as it requires no Object scripting!) But how do I get the Display message associated with that hotspot to change after that event has occurred? And regardless of if the character has that inventory item or not (idea is they already searched the stump.)
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

Khris

While the answer to this can be hard to find, it's one of the most frequently asked questions ever. If the wiki doesn't address this, it's high time it did.

If the reaction is only going to change once, you can use the special function Game.DoOnceOnly() for this:

Code: ags
function hStump_Interact() {

  if (Game.DoOnceOnly("search stump")) {
    Display("You find a coin.");
    player.AddInventory(iCoin);
  }
  else {
    Display("You search the stump again but find nothing else.");
  }
}


What this function does is simply return true for each unique string the first time, then false every time after.


The alternate and more flexible method is to use a variable. A room variable is enough here since you'll only going to check the game state in the room with the tree stump.

Put this at the top of the room script:
Code: ags
bool stump_searched;  // initial value if not specified: false


You can now change the value and check for it:

Code: ags
function hStump_Interact() {

  if (stump_searched) {
    Display("You search the stump again but find nothing else.");
  }
  else {
    Display("You find a coin.");
    player.AddInventory(iCoin);
    stump_searched = true;    // change the variable's value to true
  }
}


This is more flexible because you can define the variable as int, then set it to different numbers. For instance repeated searching could generate a third message.

FamousAdventurer77

I'm going to go with the DoOnceOnly one for now with the tree stump, will give the variable method a shot in with a different hotspot in another room of my This-Is-A-Learning-Experience-Adventure. Thanks so much!

Next step: connect the rooms.

Also, any way I can get the test-run upon hitting F5 to show up bigger? At least a bigger window if not full screen? The entire window comes in at the teeny 320x200 resolution which makes things incredibly hard to see.
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

Khris

Press F7 in AGS, then go to the game's Compiled folder via the Windows Explorer and run winsetup.exe.
Change the filter to x3 or x4 depending on your Desktop resolution, then click "Save".

Pressing F5 in AGS will now use the changed acsetup.cfg i.e. run the game with the filter.

And in case you missed this, here's a link to Densming's video tutorials:
http://www.youtube.com/densming#p/c/21DB402CB4DAEAEF/0/1Ml_DR76Cl4

FamousAdventurer77

This is a hi-res monitor, but I ran it at 4X and came out like what I'd probably expect it to look like full-screen since I'm using VGA-style backgrounds.

When I'm ready to compile the "real thing" though, will it just replace those other files in that folder?

Thanks for the tutorials link-- bookmarked, I'll definitely be referencing those. For now I just fast-forwarded to vid #14 on how to transition rooms but I'll watch the entire series when my attention span kicks in again.

I'm also trying to take it slow and do very basic stuff first before moving onto more complex scripting events and commands, then graphical niceties come later, ie, trying to figure how to get that freakin control panel to show up correctly and do things with the inventory before I get into other characters, dialogs, and character deaths.

Thanks again for your help!
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

Khris

Quote from: FamousAdventurer77 on Tue 24/05/2011 02:08:42When I'm ready to compile the "real thing" though, will it just replace those other files in that folder?

F7 does compile the real thing; if you hit F5, AGS compiles a debug version; this ends up in the Debug folder and is run from there, but still uses the Compiled folder as working dir (i.e. the cfg file in there or any other assets).
F7 is what you'd use at the very end to create the actual game; every time you press it, all files in the Compiled directory are overwritten.

A short note about the vids: they are in general very good and seem to have proven invaluable for beginners; they do feature some slightly awkward methods on occasion though. Of course it's impossible to detect those if you don't know the engine at all, just don't be surprised if something is handled differently in a thread in the forums.

FamousAdventurer77

Noted. But I'm open to learning different techniques, then using whichever one I find easiest or appropriate to the room/event/etc. After all scripting has some room for experimentation and trying new things, it's not like doing taxes. (I'd know, I'm an EA.)
If you want to know the Bible's contents, just watch Lord of the Rings or listen to the last 8 Blind Guardian albums. It's pretty much the same thing.

SMF spam blocked by CleanTalk