Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Molin on Mon 11/08/2003 14:25:11

Title: Simple interaction questions.
Post by: Molin on Mon 11/08/2003 14:25:11
Hi all.
Im new to this editor and i like it so far.
I have some questions about scripting a few cursor and action related issues.

First of, I want to "copy" the functionality of the "Beneath a steel sky" cursor behaviour.

SO... Is there a way that one can script a global function that does this..
SetCursorMode() to swap cursorgfx and mode over hotspots. THEN change back when the user exits the hotspot.
LEFTCLICK should be "lookat" and RIGHTCLICK should be "interact/use".

Thx for any help or pointers...
ALSO i dont use the beta version of the AGS so i cant use any lucasarts GUI that you guys have posted that probably have these funtions.
Title: Re:Simple interaction questions.
Post by: Scummbuddy on Mon 11/08/2003 16:30:35
why not, the final version 2.56 has been posted in the technical forum.  ;)
Title: Re:Simple interaction questions.
Post by: Molin on Mon 11/08/2003 17:04:39
hm they dont have what i am looking for. Any help on what i just asked? anyone?
Title: Re:Simple interaction questions.
Post by: Ginny on Mon 11/08/2003 17:48:59
Ok, I think this is the way to do it:

First of all, as I understand, you want the cursor to change to talking mode when over characters, use mode when over hotspots and objects, and walk mode when on nothing. And you want right clicking to run the appropriate interaction. In left click, you want it to look at the object/hotspot/character.

So, in the on_mouse_click function:

 else if (button==LEFT) {
   ProcessClick(mouse.x, mouse.y, MODE_LOOK); // look mode
 }
 else {   // right-click
     ProcessClick(mouse.x, mouse.y, GetCursorMode()); // the currently selected mode
 }

And in repeatedly_execute:

 if ((GetLocationType(mouse.x,mouse.y)==1) || (GetLocationType(mouse.x,mouse.y==3)) {
 SetCursorMode(2); // use mode on characters and hotspots
 }

 else if (GetLocationType(mouse.x,mouse.y)==2) {
 SetCursorMode(3); // talk mode on characters
 }
 else if (GetLocationType(mouse.x,mouse.y)==0) {
 SetCursorMode(0); // walk mode on nothing
 }

This should work.

Also, I would use left click for interactions and right click for looking, but however you want :).

P.s. You should probably turn off the normal interface, and have the inventory popup when a certain key is pressed for example, or aomething like that. :)

I used the newest version, but it'll work in the older one too (2.55).
I reccomend downloading th new version though, it has many new features! :)
Title: Re:Simple interaction questions.
Post by: Molin on Mon 11/08/2003 18:01:58
hey hey hey!!! O NICE!  ;D

Thx a bunch GinnyW!.  I begin to understand the syntax and script structure as well now so pretty soon ill be off on my own wings.

Ill try installing it and try it out!

Title: Re:Simple interaction questions.
Post by: Ginny on Mon 11/08/2003 18:10:58
You welcome ;)

I too am just starting out, though I've been registered for almost a year here :P.
I suppose I just didn't have time, but now that I've started I love it! ;D :)
Title: Re:Simple interaction questions.
Post by: Proskrito on Mon 11/08/2003 18:11:02
Quote from: GinnyW on Mon 11/08/2003 17:48:59
And in repeatedly_execute:

 if ((GetLocationType(mouse.x,mouse.y)==1) || (GetLocationType(mouse.x,mouse.y==3)) {
 SetCursorMode(2); // use mode on characters and hotspots
 }
Oh GinnyW forgot a ')' !  ;)
that should be:
if ((GetLocationType(mouse.x,mouse.y)==1) || (GetLocationType(mouse.x,mouse.y)==3)){
 SetCursorMode(2);
}
just in case  :)
Title: Re:Simple interaction questions.
Post by: Ginny on Mon 11/08/2003 18:16:14
Oops, lol.. ;)
It's strange that in the editor there is a ')' there, I tested this on a blank game you see.
Maybe it just got erased when I copied it, hehe.
Title: Re:Simple interaction questions.
Post by: Molin on Mon 11/08/2003 18:20:27
hehe i did notice the missing bracket. No prb i figured it out though BUT bunch of thx for helping me with the script!

now ill try just to get rid of that clock appearing every now and then.... 8) a flickering mousecursor is wery annoying.
Title: Re:Simple interaction questions.
Post by: Molin on Mon 11/08/2003 18:43:37
i added a statement so that i can walk with the left button.

else if (button==LEFT && GetCursorMode() == 2 ) {
ProcessClick(mouse.x, mouse.y, MODE_LOOK); // look mode
}
else if (button==LEFT && GetCursorMode() == 0 ) {
ProcessClick(mouse.x, mouse.y, MODE_WALK); // walk mode
}
else { // right-click
ProcessClick(mouse.x, mouse.y, GetCursorMode()); // the currently selected mode


It would probably be nicer with a variable to set instead of all the ifstatements.. but heyit works anyway...:P
Title: Re:Simple interaction questions.
Post by: Ginny on Mon 11/08/2003 18:52:46
Great idea! Looks like you're a very quick learner :).

edit:
I found a little fault with this, when you take an inventory item out of the inventory, it dissapears since the mode is changed, so here is a slicht change:

if (character[GetPlayerCharacter()].activeinv == -1) {
 if ((GetLocationType(mouse.x,mouse.y)==1) || (GetLocationType(mouse.x,mouse.y)==3)) {
 SetCursorMode(2);
 SetMouseCursor(2);
 }

 else if (GetLocationType(mouse.x,mouse.y)==2) {
 SetCursorMode(3);
 SetMouseCursor(3);
 }
 else if (GetLocationType(mouse.x,mouse.y)==0) {
 SetCursorMode(0);
 SetMouseCursor(0);
 }
}

Now items will stay selected.
Also:

 else if (button==LEFT) {
  if (character[GetPlayerCharacter()].activeinv == -1) {
   ProcessClick(mouse.x, mouse.y, MODE_LOOK);
  }
  else {
    RunInventoryInteraction (character[GetPlayerCharacter()].activeinv, MODE_LOOK);
  }
 }

I did this so that if the character is holding and item, he would look at the item he's "holding" instead of whatever is on the screen.

:)
Title: Re:Simple interaction questions.
Post by: Molin on Tue 12/08/2003 08:55:45
hey man
thx a bunch!. I havent gotten to the ui handling as of yet.
I have done this simple ui slider though...

// <DM> define ui timer
int timer = -22; //timer equals the ui height -1
function repeatedly_execute() {
// put anything you want to happen every game cycle here

// <DM> UI slidedown
if (mouse.y <= (timer+23))
{
 if (timer <= -1) {
   timer++; SetGUIPosition(2,0,timer);
 }
}
// <DM> UI slideup
else
{
 if (timer >= -22) {
   timer--; SetGUIPosition(2,0,timer);
 }
}
/Molin
Title: Re:Simple interaction questions.
Post by: on Sat 16/08/2003 18:51:53
I wonder if it is possible to display the name of an hotspot or object next to the cursor while the cursor is over the object or hotspot.
I´ve done a search in the forums, but without any results that helped me.


just like in BASS.

that whould be great!

greetingz ,
Martin

P.S.: I have to apologize for my bad englisch skills, it isn´t my native anguage!
Title: Re:Simple interaction questions.
Post by: Molin on Sat 16/08/2003 21:51:28
yo martinreichl
i did this for you  .. it does what you wanted...
click to go to the post...

http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=7913
Title: Re:Simple interaction questions.
Post by: on Sun 17/08/2003 23:34:33
lol at Ginny, i've only just started, even though I've followed AGS since the dos versions. :)
Title: Re:Simple interaction questions.
Post by: on Wed 20/08/2003 20:10:27
thank you very very much Molin!

it works perfectlyyyyyy!  

very nice people here!