two questions about ags

Started by TheSaint, Sun 16/05/2004 23:41:37

Previous topic - Next topic

TheSaint

hi folks,
i have two questions that are bothering me atm.
1. when i use multi-directional system of character views (north,south,east,west,en,wn,sw,se) player character starts to behave weirdly - for example walking north backwards or walking to the right facing upper-right directions, or turns around couple times(2 circles) before starting goof-walking. anyone experienced something like this or has idea how to solve it? i was trying different approaches but had no success.
2. when i try to use inventory on hotspot using interaction editor - for example open door with key - how do i specify exact item/key i would like to use?
editor looks like this:
(-) Use inventory on hotspot
|____ Player walk to hotspot
|____ Player face hotspot
|____ Player go to next room

cheers,
TheSaint

Scorpiorus

1. Make sure you have set up loops in a right way:

From the manul:

The "Normal view" is where you set what the character looks like. You must create a view in the View Editor, and this view must have either 4 or 8 loops. If you use 4 loops, then when walking diagonally the closest straight direction is used for the graphics. Each loop is used for the character walking in one direction, as follows:

Loop 0 - walking down (towards screen)
Loop 1 - walking left
Loop 2 - walking right
Loop 3 - walking up (away from screen)
Loop 4 - walking diagonally down-right
Loop 5 - walking diagonally up-right
Loop 6 - walking diagonally down-left
Loop 7 - walking diagonally up-left


2. You need to use a conditional:
(-) Use inventory on hotspot
 |____Conditional - If inventory item was used
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  |____ Player walk to hotspot
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  |____ Player face hotspot
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  |____ Player go to next room


TheSaint

#2
thnx for prompt reply,
1. i have used atm only 6 of eight character positions, but those are correctly placed for sure. can it be a problem that 2 arent defined yet?
2. how do i define conditional in this case? since its not followed by code but by 3 more entries(walk,face,newroom)

i've found this in manual(edit a bit):
if (player.inv[12] == 1) {Ã,  Ã, 
Ã,  Ã,  NewRoom (10);
Ã,  }
but if I'm not wrong it checks player inventory for certain item and if its there (==1 boolean right?) it does newroom(10)

are these entries walk,face, and new rooms just organized like procedures in pascal? pre-defined but user can write same thing without calling for them by writing in run script editor? and where can i look at code that these "procedures" are made from?

[edit: this thing i made works but I'm not sure if it will work for each item in inventory(actually I'm pretty sure it will) and i want for example it to work for one of 3 key I'm carrying, so i select key i want, i move it(cursor) to hotspot and click on it so it opens door.]

cheers,
TheSaint

Scorpiorus

Quote from: TheSaint on Mon 17/05/2004 00:17:181. i have used atm only 6 of eight character positions, but those are correctly placed for sure. can it be a problem that 2 arent defined yet?
Probably, in that case goto characters pane, select the character and tick No diagonal loops. Thus he won't use loops 4,5,6 and 7 at all. Later, you can uncheck it (after finishing with making these extra loops).

Quote2. how do i define conditional in this case? since its not followed by code but by 3 more entries(walk,face,newroom)
To make it easier, delete all the actions you already put and start it again. Use inventory on hotspot, next Conditional - If inventory item was used (3), since 3 is the number of the key item, and then add after conditional walk, face and new room respectively. Make them nested to Conditional!

Quotei've found this in manual(edit a bit):
if (player.inv[12] == 1) {Ã,  Ã, 
Ã,  Ã,  NewRoom (10);
Ã,  }
but if I'm not wrong it checks player inventory for certain item and if its there (==1 boolean right?) it does newroom(10)
Yep, the player will go to the new room if he has that item (he doesn't necessary need to click with that item exactly).

Quoteare these entries walk,face, and new rooms just organized like procedures in pascal? pre-defined but user can write same thing without calling for them by writing in run script editor?
Yes, you can use the text script and just call appropriate procedures (or functions).

Quoteand where can i look at code that these "procedures" are made from?
They are built in AGS, you can't see their realization.

Quote[edit: this thing i made works but I'm not sure if it will work for each item in inventory(actually I'm pretty sure it will) and i want for example it to work for one of 3 key I'm carrying, so i select key i want, i move it(cursor) to hotspot and click on it so it opens door.]
if (player.activeinv == 3) {

// you code here

}

that was the code will be executed only if the key is an active item.

TheSaint

right, thnx i thought that was the case but its better to ask if ur not sure, tho i think its better to learn on ur own coding mistakes. one more thing: can i just write code and then save it in some script so i can call it as procedure just like those events? in case that yellow key opens 2 doors, red 5 doors etc.

cheerZ,
TheSaint

Scorpiorus

Yes, in that case you write a function in the global script and import it via the script header:

main global script:

function MyCode(int itemNumber) {

   if (player.activeinv == itemNumber) {

      // your code here

   }

}


script header:

import function MyCode(int itemNumber);



use inventory on hotspot - RunScript:

   MyCode(3); //passing item number as parameter

TheSaint

ok, just few more:

u r using int itemNumber , afaik its declaration for variables in all programming languages so basicly i can use x,y... too right?

and something more player.activeinv this line is using object oriented programming, where player is class. where can i find declarations, definitions and functions that are pre-built? i need a list of those for coding.
thnx for help btw.

greetZ,
TheSaint

Scorpiorus

#7
Quote from: TheSaint on Tue 18/05/2004 15:04:12you are using int itemNumber , afaik its declaration for variables in all programming languages so basicly i can use x,y... too right?
Yep, you can use any name you like as long as it begins with a letter or underscore character and there are no spaces. Well, just like in any other language. :)

Quoteand something more player.activeinv this line is using object oriented programming, where player is class. where can i find declarations, definitions and functions that are pre-built? i need a list of those for coding.
AGS script language is not object oriented, a dot operator is used to access variables within the struct. But it's a C-struct (not C++ one). In AGS you can't declare function members (i.e. methods) nor inherit struct to build new types. What you do, is use appropriate AGS script funtions to manipulate variables, move objects or characters or play animation sequences.

You can find all the AGS script functions in the manual, as for structs' variable check out "Text script global variables". You'll find all information required. If you are still interested how these structs declared see the following topic in the Technical Archive: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=12142.0 But keep in mind - not all of the global variables can be written into, for instance it's not a good idea to set a character walking speed this way:

character[EGO].walkspeed=5;

Use appropriate script function instead:

SetCharacterSpeed(EGO, 5);

Ginny

Quote from: Scorpiorus on Mon 17/05/2004 21:48:47
script header:

import function MyCode(int itemNumber);

isn't is supposed to be: import function MyCode(int); when it's in the script header? It just seemed out of place, as I remembered it differently. :) Was this changed recently?
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

You can have it in either way, it really doesn't matter. But if you didn't specify variable's name it won't appear during the autocompletion parameters list feature(when you open a bracket after have written function's name). :)

Ginny

Oh, I see, i must've been still on old information, since the manual says it should be types only. But after autocomplete for custom functions was implemented, the int names should be used too? :)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

In fact, it was that way all the time since the import feature was implemented. It just the manual where the example is written without names. Again, you can write it as you like. But if you do write with names then the names will be shown in a calltip.
And all AGS built-in functions declared with names, otherwise a calltip for AnimateCharacterEx() would be:
AnimateCharacterEx (int, int, int, int, int, int) - isn't very informative, is it? :)


Ginny

Yep, makes sense.. Funny how the manual says (and I quote) "...of the parameter TYPES ONLY...", maybe that should be updated. Anyway, thanks for the tip ;).
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Scorpiorus

#13
Yeah, it states so. Maybe the very very first version (in which the import was just added) did indeed require only types, I'm not sure here. Still, yep, at present there is some inconsistency with what the manual says.

EDIT:
Scummbuddy, thanks for moving it to the technical forum.

SMF spam blocked by CleanTalk