I need help with single cursor interface

Started by adevin, Wed 02/11/2005 03:39:45

Previous topic - Next topic

adevin

Hello,
I have some ideas for a game I'm working on and I'm having alot of trouble. I'm unable to do any scripting at this point, so if it's possible I'd like to keep it as simple as possible.
What I would like to do is to get rid of the icon bar GUI completely, and have only one mouse cursor that the player can use in my game. Right clicking will open the inventory, and left clicking will cause the main character to interact with whatever is clicked on. I can't figure out how to do this, and I would really appreciate some help. Sorry if my explanation of what I'm after was confusing, I'll try to elaborate if there's confusion.
Thanks

SSH

Well, you'll have to do a little dabbling in scripting to do that. Or, alternately, use a template from a game that has an interface like the one you want. I'm afarid I don't knwo which template will be like this.


If you're going to go into scripting,  you'll need to modify on_mouse_click function.
12

Ashen

Try Rui's page for templates. I think the Verb Coin, Broken Sword and ALARCOST ones are nearest to what you want.

However, as SSH said, you're going to need to do a bit of tinkering with the script, whatever you do. (If only to update the code to a newer AGS version.)
I know what you're thinking ... Don't think that.

Elliott Hird

Go to the gui section, select iconbar and change the thing from Normal to Popup Modal. Then go into the global script, add at the very top a line saying string buffer; scroll down to on_mouse_click, put and replace everything between the { and } with this:
Code: ags
if (button == eMouseLeft) {
  GetLocationName(mouse.x, mouse.y, buffer);
  if (buffer == "") ProcessClick(mouse.x, mouse.y, eModeWalkto);
  else ProcessClick(mouse.x, mouse.y eModeInteract);
}
else {
  show_inventory_window();
}
make all interactions with the Interact cursor. Done!

adevin

I appreciate the replies. I tried making the changes that Elliott suggested to the script, and I received an error message after trying to save my game:

Error (Line 45): undefined symbol 'eMouseLeft'

What am I doing wrong? Thanks again for the help.

Gilbert

Which version of AGS are you using? The codes Elliott posted requires V2.71 (which  isn't a good idea as it's not officially released yet).

Elliott Hird

eMouseLeft is just standard. wait, lemme check

2.7 code:
Code: ags
if (button == eMouseLeft) {
  GetLocationName(mouse.x, mouse.y, buffer);
  if (StrComp(buffer, "") == 0) ProcessClick(mouse.x, mouse.y, eModeWalkto);
  else ProcessClick(mouse.x, mouse.y eModeInteract);
}
else {
  show_inventory_window();
}


2.62 code (time to upgrade!):
Code: ags
if (button == LEFT) {
  GetLocationName(mouse.x, mouse.y, buffer);
  if (buffer == "") ProcessClick(mouse.x, mouse.y, MODE_WALK);
  else ProcessClick(mouse.x, mouse.y MODE_USE);
}
else {
  show_inventory_window();
}
You might have to change MODE_USE to MODE_INTERACT, I can't remember.

Gilbert

Your's was not V2.62 code, as there's if (buffer=="")

That's why I said your original codes were for V2.71, not V2.7.

Elliott Hird

Ups, in the 2.62 code replace buffer == "" to StrComp(buffer, "") == 0

adevin

I am using 2.6, and I have made all the changes that you said to with this version, but now there is another problem:

Error (line 50): Parse error in expr near 'mouse'


Line 50 looks like this:
else ProcessClick(mouse.x, mouse.y MODE_USE);

Ashen

#10
There's a missing comma after mouse.y:

else ProcessClick(mouse.x, mouse.y, MODE_USE);

It might be worth your time reading through the manual (which you should've done already), to familiarise yourself with the commands, and how to use them.

And, of course, if you haven't made a major start you're probably better switching to 2.7+ now rather than later.
I know what you're thinking ... Don't think that.

Elliott Hird

Downloading the beta would be good too, although it IS experamental and possible unstable.

FlyRider

I have a question. What if you want a pop-up menu whith "talk to, use, look at" etc to appear when clicking on something? And depending on what choice you make there, the player talks to, interacts with or looks at the thing.

What additional code is required for that?

Ashen

Do a search for Verb Coin interfaces, or use the template on Rui's site.
I know what you're thinking ... Don't think that.

adevin

Sorry to bother you all with this again, but I've just gotten to the point where I'm adding an inventory item that the player will be using on the main character. But there's a problem: when I try to use the item on the character, it just displays the message that I assigned to his "Interact" mode. I realize this is because I did that scripting to make all left clicks "interact". How can I change the scripting to get around this problem?

I will try to explain my problem more if I'm not clear enough.

Ashen

#15
You need to add a check in on_mouse_click to see if there's an active inventory item to use. Something like (assuming you're still using 2.62, and the same basic code as above):
Code: ags
if (button == LEFT) {
  GetLocationName(mouse.x, mouse.y, buffer);
  if (StrComp("", buffer) == 0) ProcessClick(mouse.x, mouse.y, MODE_WALK);
  else if (player.activeinv != 0) ProcessClick(mouse.x, mouse.y, MODE_USEINV);
  else ProcessClick(mouse.x, mouse.y, MODE_USE);
}


(If you're not using either of those any more, you'll need to be more specific about what you are using.)
I know what you're thinking ... Don't think that.

adevin

Yes, I'm still using 2.6

I put this in the script, and now I got the inventory item interactions to work, but the character won't respond to his usual left click interactions that don't involve inventory items. Is there something else I need to add to the script?

Elliott Hird

I have no idea why it isn't working - are you clearing the inventory item after interaction?

adevin

Yes I am. The interactions don't work even at the start of the game when inventory interactions haven't been used.

Ashen

I don't know why this isn't working either ...

Is the character responding to any clicks (can you get him to react to inventory items)?
Do other characters/object run their interactions normally? (inventory & non-inventory)
Have you changed player characters - 2.6 doesn't update the player pointer.

(There was also a comma missing from the code I gave - the same mistake frome a few posts up  :-[ as I copied the code without checking it - but since that'd cause a crash, I'll assume you noticed & fixed it yourself.)
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk