Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Tue 11/01/2005 01:13:46

Title: function game_start comand [SOLVED]
Post by: on Tue 11/01/2005 01:13:46
for a function game_start comand it keeps telling me my character is not in the room. how do you set it to a room? ???
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 01:34:29
The game_start function is run before the first room is loaded, so there's no room any player could currently be in.

What command do you use, what do you want to do?
You probably want to put the code in the "Player enters screen" interaction of the room.
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 01:40:04
i want my guy to move through rooms in a path.
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 01:56:33
Do you mean the player character? For a cutscene for example?

Ok, here's an example, assuming player is in room 1 and should move to room 2:


// script for interaction that triggers cutscene (e.g. interact with object in room 1)
//...

  if (GetGlobalInt(77) == 0) { // if cutscene hasn't run already
    MoveCharacterBlocking(GetPlayerCharacter(), 320, 150); // walk to right edge of room 1
    SetGlobalInt(77, 1); // set flag to 1, so cutscene will be continued in room 2
    NewRoomEx(2, 50, 150); // change to room 2, left edge
  }

//...



// script for room 2: Player enters screen (after fadein)
//...

  if (GetGlobalInt(77) == 1) { // if flag is set to 1, i.e. cutscene should be continued
    MoveCharacterBlocking(GetPlayerCharacter(), 160, 160); // move player to middle of room 2
    DisplaySpeech(GetPlayerCharacter(), "Phew, that was quite a walk!");
    SetGlobalInt(77, 2); // set flag to 2 so cutscene doesn't run next time you enter this room and object interaction in room 1 can't be done again
  }

//...
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 01:58:27
i ment a npc. for ex. a npc that moves around rooms and you are trying to avoid him
Title: Re: function game_start comand
Post by: Gilbert on Tue 11/01/2005 02:07:29
What did you do there? Did you move or animate a character in game_start()?
Since no room file and game data was loaded during game_start() you shall not do that. The game_start() function is only used for initializations such as turning on/off GUIs, assigning values to variables, etc.

If you want to do something with a character upon start of the game, do that in the "Player enter screen" (before or after fadein, depending on your needs) event of that room.
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 02:16:17
Oh my, that's tricky.
Only one room can be loaded at a time, so you can't directly move NPCs in other rooms since they are not in memory.
There are workarounds, but they are quite complex.
You might want to take a look at the CCS plugin (http://geocities.com/scorpiorus82/), that's quite easy to use.
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 02:21:23
i did but i cant get that one to work :'(
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 02:28:30
Please, you have to provide more information.

What specifically are you having problems with? What doesn't work?
What error messages do you get?
What SHOULD happen and what DOES happen?
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 02:34:26
it keeps saying that it cant recognize the commands


ive told it to use the plugin and ive even tried to copy the demo game to check if I'm entering it wrong but it wont let me get into the tester
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 02:45:41
Have you put ags_CCS102.dll in both the AGS editor folder and the game's Compiled folder?
Have you checked the plugin in menu "Game" -> "Plugin editor..."?
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 02:48:01
ya i did and i slected it in the manager
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 02:53:33
Quoteit keeps saying that it cant reconise the comands

What are the commands?
The error messages give you the line number or take you directly to the part of the code that's wrong. Please post these lines here.
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 03:00:03
for ex.

ccCreateCommand(1, "ROOM:2,200,110;MOVE:325,110;ROOM:1,0,110;MOVE:200,110;");
ccExecuteCommand(PERSON,1);
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 03:09:06
Hm, looks ok to me.
Can you play the demo that is included with the plugin?
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 03:09:42
ya i can
Title: Re: function game_start comand
Post by: strazer on Tue 11/01/2005 03:18:04
If you have the dll in the right places and have the plugin activated, it should work fine.
If all else fails, you could upload your game for us to take a look at.
Title: Re: function game_start comand
Post by: mport2004 on Tue 11/01/2005 03:19:35
k. thx ill try to look into it. :-\
Title: Re: function game_start comand
Post by: Scorpiorus on Tue 11/01/2005 18:03:16
Quote from: mport2004 on Tue 11/01/2005 03:00:03ccCreateCommand(1, "ROOM:2,200,110;MOVE:325,110;ROOM:1,0,110;MOVE:200,110;");
ccExecuteCommand(PERSON,1);

Hmm, I tried this command and it's parsed fine for me.

There was a bug in the plugin which I've just fixed. I don't, however, see how it could affect ccExecuteCommand not recognizing commands since it was about a read-access issue.

Anyway, try dowloading a new version (1.03) from here: http://geocities.com/scorpiorus82/

Let us know how does it turn out. ;)
Title: Re: function game_start comand
Post by: mport2004 on Wed 12/01/2005 17:42:10
k thanks for the help ill try it.
Title: a question for Scorpiorus
Post by: mport2004 on Wed 12/01/2005 22:56:37
i was trying ccs again and i got the error mesages to stop comming up but the ccExecuteCommand wont work.
Title: Re: function game_start comand
Post by: Scorpiorus on Thu 13/01/2005 00:07:34
Ok, let's figure out what's wrong...

What do you mean by "ccExecuteCommand wont work"? Doesn't the character move? Does it display some kind of an error message?

What CCS code do you have? And where did you put it?

Try the following code to test:

function game_start() {

   ccDebug(1);
   ccSetBlankView(SOME_BLANK_VIEW_HERE);

   character[PERSON].room = character[GetPlayerCharacter()].room;

   ccCreateCommand(1, "MOVE: 200, 100; MOVE: 100, 100; GOTO:1;");

  ccExecuteCommand(PERSON, 1);
}

Take a look at the debug info when running the game. It tells NPC's room, current CCS action, frame, etc.
Title: Re: function game_start comand
Post by: mport2004 on Thu 13/01/2005 17:24:43
Wow it worked! :o

i dont know why, i had the ccSetBlankView and the ccCreateCommand and the ccExecuteCommand and the ccDebug

but i dident have the
character[PERSON].room = character[GetPlayerCharacter()].room;
was that why my probraming dident work?
Title: Re: function game_start comand
Post by: Scorpiorus on Thu 13/01/2005 18:16:41
Quotebut i dident have the
character[PERSON].room = character[GetPlayerCharacter()].room;
was that why my probraming dident work?
This piece of code places PERSON into the current room. You probably had him in another room (maybe room -1) and thus didn't see his moving.

But do put ccDebug(1) at game_start. This way you should at least see a debug text line shuttling around the room. :)
Title: Re: function game_start comand [SOLVED]
Post by: mport2004 on Fri 14/01/2005 02:24:50
lol ya i put the blank view as a blue cup top see what would happen and there was a blue cup moving in the next room.

thanks for all the help :) :)


um also do you need the spaces before the comands??
Title: Re: function game_start comand [SOLVED]
Post by: TerranRich on Fri 14/01/2005 03:42:20
No, it's just for organization.
Title: Re: function game_start comand [SOLVED]
Post by: Scorpiorus on Fri 14/01/2005 09:44:13
Quote from: mport2004 on Fri 14/01/2005 02:24:50
lol ya i put the blank view as a blue cup top see what would happen and there was a blue cup moving in the next room.
Yeah, that's a good idea to use a non-transparent sprite to have some kind of a radar. ;)


As for spaces, as TerranRich has already pointed out, that's not necessarily (but preferable for readability), and in fact in the first versions of the plugin it was required to type a command line with no spaces at all. Currently, the plugin reference also states that you can't have spaces between command parameters but in reality it seems to parse them fine as well.
A colon, however, is a part of the command therefore it's not allowed to separate, say, 'MOVE' and ':'