Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ManicMatt on Wed 11/01/2006 14:26:37

Title: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 14:26:37
Sorry but I didn't really know what to call my problem!

Take a look at this picture:

(http://i16.photobucket.com/albums/b37/manicmatt/labentrancedarkexample.png)

My EGO can interact with the skip, and climb onto it (and now he's stuck on a non-walkable area until he interacts with the skip again and thus climbs back down again). However I now have the problem of him still being able to interact with everything else in the room. He'll just stand there stuck and pick up things in the room as if by magic.

I've already done EVERYTHING in the scene, all the interactions etc.

One idea I had was to make my character change rooms, by showing a room that's just a picture of the EGO up close or something, and then taking him back to the room and now he is back on the ground again. This would work, but break up the flow of the game and look a bit crap I think.

I think integers if/else and all that might work, but looking at the tutorials Ashen posted recently I don't understand how to do it.

Unless someone is able to explain it better (A guide for beginner's my ass!Ã,  :P ) or please offer an alternative method, I'll have to go with the room jumping idea.

Thanks!
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 15:09:40
Yes, you can use variables to do this.

Just add a boolean variable to the room script file:


bool PlayerIsOnSkip;


When the player enters the screen: set it to "false", so that it actually starts with a "false" value (because the player starts not being on the skip of course):


PlayerIsOnSkip = false;


Now, whenever the player is climbing up the skip, set it to "true":


PlayerIsOnSkip = true;


And whenever he leaves it, set it to "false":


PlayerIsOnSkip = false;


Now you have created a variable, that will ALWAYS tell you whether the player is currently on the skip or not! BUT: it won't do anything yet.
So, now you need to include an if-statement into all interactions that you want to disable when the player is on the skip:


if ( !PlayerIsOnSkip )
// if player is currently NOT on skip
{
   // do stuff
}


This way, you can also allow some interactions ONLY if the player is on the skip.

For closer information, re-read parts of the variables-tutorial.

Hope I could help.
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 15:47:58
Thanks, that's really helpful!

But I can't get it to work exactly right.

(http://i16.photobucket.com/albums/b37/manicmatt/script.png)

When on the skip he will follow about the first two commands AFTER the first "run script" and then use the script.

Am I going to have to take all that stuff that's been done in the interaction menu and type it out into one big script file? Would that do it? (If really time consuming and boring)

EDIT: Crap I just noticed the same thing happens regardless of whether he's on the skip or not..
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 16:00:06
Yep, you'll have to learn all the real script commands and place them underneath your "cEgo.Say ( "Whatever" );" line!

It'll take some time, but don't worry - if you ever plan on becoming just a little more interested in coding more complex things (like custom GUIs etc.) you'll need to get rid of those "shortcuts" anyways.

EDIT: And you'll have to move the line "bool PlayerIsOnSkip" to the global room script file!
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 16:11:17
global room script file? Where is that???

Should I point out that the script you've seen is automatically placed in the global script anyway? Me confused.

Should my script have the "else" in it for when he's not on the skip?

EDIT:

I'm going to beat my head against a wall soon.

Please rectify!

function character9_c() {
  // script for Character 9 (Vagrant): Use inventory on character
bool PlayerIsOnSkip;
if ( !PlayerIsOnSkip ):
character[EGO].Say("I need to get down first.");
return;   {
}
else; {
character[EGO].Say("I don't need to get down first.");
}
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 16:35:19
To view the room script file (sorry for calling it global before, that way a typo), load up a room and hit CTRL+E.

Then make "bool PlayerIsOnSkip;" the first line there.

You can use else, but you'll still have to move all the interactions from the editor to the script!
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 16:38:46
Thanks for clearing that up. I'll do that now.

Sorry, I mean it's saying "parsar error" about the else bit.
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 16:41:25
Get rid of the ; - an else-statement doesn't need one (as if's don't need any)!


if ( x == y )
{
   // do something
}
else
{
   // do something else
}
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 16:48:24
It says:

parser error: unexpected "else"

PS - Good thing you're patient. You are patient, right?

(Note to self - must credit dkh in my game)
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 16:51:23
;D I am patient, I hope you are!

Also, delete the opening bracket ( { ) after the return; - line.

And delete the "bool PlayerIsOnSkip" and place it on top if that room script file (the CTRL+E one)! Then it should work!
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 17:08:23
okay buddy, next problem! We'll get through this!  8)

function character9_c() {
  // script for Character 9 (Vagrant): Use inventory on character
if ( !PlayerIsOnSkip )
{
character[EGO].Say("I need to get down first.");
return;   
}
else
{
character[EGO].Say("I don't need to get down first.");
}
}

Just having the bool bit in the room script and not on the global one, as shown here, makes it say that playerisonskip is an undefined symbol.
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 17:15:46
Argh, sorry for this... I am really tired today.

Move that line again. This time out of the room script file and into the global script file (CTRL+G - (to the top). Then write this to the script header (CTRL + H):


import bool PlayerIsOnSkip;


Solving those problems is really hard when you don't have the game in AGS in front of you.

Hope it works now!
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 17:25:45
next error message!:

unable to create local script: Runtime error: Unresolved import 'PlayerIs etc..'

What the heck does that mean?
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 17:30:17
Are you sure, that you have:


bool PlayerIsOnSkip;


at the top of your global script file (CTRL+G) and:


import bool PlayerIsOnSkip;


in your global header file (CTRL+H)?

This error shouldn't occur if you have both lines in place.

Sorry for being not so helpful, don't know what it is today...
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 17:46:26
Don't worry about it, I'd be totally lost without you!

Yes, i believe so..

// main global script file
bool PlayerIsOnSkip;

and...

import bool PlayerIsOnSkip;
// Main header script - this will be included into every script in
// the game (local and global). Do not place functions here; rather,
// place import definitions and #define names here to be used by all
// scripts.


Does it matter that I'm using the most up to date AGS?

EDIT: (Cos I am!)
Title: Re: non walkable area and integers
Post by: strazer on Wed 11/01/2006 17:53:50
You have to export variables first so you can import them:

// main global script file
bool PlayerIsOnSkip;
export PlayerIsOnSkip;
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 17:59:58
YES!!!!!!!!!  :D

That did it!

*Adds Strazer to the credits' thanks list*

Thanks a million guys! Now on to the commands...

(Don't worry, I should be able to handle it from here!)

Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 18:08:51
Wait a second, how come that I don't have to export them??

I can just define and import them in the header! I double-checked.
Title: Re: non walkable area and integers
Post by: strazer on Wed 11/01/2006 19:18:55
Defining variables in the header creates separate instances of the variable for the global script and each room. Changing the value from within a room script then doesn't affect the variable in the global script.

So if you need global variables, define them in the global script, export them and import them in the global script header.
Title: Re: non walkable area and integers
Post by: DoorKnobHandle on Wed 11/01/2006 19:22:10
Ah yes, thanks a bunch. *knocks himslef* not my day today - did I already mention that? :=
Title: Re: non walkable area and integers
Post by: ManicMatt on Wed 11/01/2006 19:39:02
*Nods and pretends to understand*

I see Strazer! (Actually, maybe I do..woah)

Just reporting in to let you both know that everything works great and now I can get on with the next location! (Yay!)