MI Style cursor.

Started by Darkmaster400, Sat 24/06/2006 20:29:18

Previous topic - Next topic

Darkmaster400

Hey guys,

Well, I am pretty new to the AGS stuff and I just finished the sprites atm (much work).
So, I want to get over to the cursors now. I am developing a Monkey Island game and
I really would like to have a MI cursor which works..

I done the sprites and the cursor interface, and I can use it.
But I replaced all the old Look, Take, Talk default stuff with same cursor..
Now I want the cursor to be 1 and not 6 or what it is..

By default the cursor is Take, Look, Walk etc etc..
I just want 1 so I dont have to cycle through all Walk, Look etc.

Hope You get my point..

EDIT:
I deleted the few lines which made the cursor cycle and now it works perfect..

Since the difficulty to make the Monkey Island GUI with Look and take and that stuff, I
am makeing my own system (you can see it in the demo I will release soon).
Anyhow, I made a hotspot, and used the interaction "Interactions > Any click on hotspot,
and then I input what was going to happend..

So I test my game but when I click on the hotspot the character only moves to it,
he wont follow what will happend, he just goes to it and nothing like if i had no hotspot,
and the things that shoulg happend wont happend..


Regards,

---
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

#1
I'm not quite clear on what you're after ...
Do you want a single cursor interface (where there's only one possible interaction for everything, and you don't need to worry whether you're Looking, Using or Talking to it), or a Verbcoin (where you click on something and a GUI appears to let you choose whetehr to Look, Use, Talk, etc)?
MI 1 & 2 used a standard LEC GUI (like these), 3 used the Verbcoin, and I'm not sure about 4.

Either way - those have been asked for many times before. Try a forum search, and check out AGS Resources for some templates that should help.

If it was something else, post again, and explain in detail what you mean.

EDIT (In response to new bit):
What mode are you using? By default, eModeWalkto doesn't trigger the 'Any click' interaction.
I know what you're thinking ... Don't think that.

Darkmaster400

Ah, well, thanks for the templates but if im using a template dont I need to start
it all over?
That would be sad cuz I worked as a animal to get this done :P

The system I am out for anyhow is that if you click on any object for example
if there is a object you can pick up, you can pick it up automatically if you click it.
If you want to open a door for example, you can just click the door and you will open it.
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

Well, you could start a new game with the template, study it's code and apply it to your existing game. (Or just copy-paste the relevant bits....)
I posted that as you where posting that you were making your own system, so it might be redundant now anyway. Although, since you said you've mostly only done the sprites, starting over shouldn't be that much work, if y.u need to.

However, you didn't answer my question:
QuoteWhat mode are you using? By default, eModeWalkto doesn't trigger the 'Any click' interaction.
Also, could you post an example of what you've got in the 'Any click' interaction. Oh, and does it only not work for hotspots, or are Characters and Objects not respnding either?
I know what you're thinking ... Don't think that.

Darkmaster400

In the "Interactions > Any click on hotspot" I have a display message, so it may
display a message when I click on the hotspot..

Hmm, I am sorry, but I dont get what you mean with the mode thing.

And no, It wont work with objects or characters either :/
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

#5
QuoteHmm, I am sorry, but I dont get what you mean with the mode thing.

Cursor mode. What cursor mode is it in, when you're clicking.
Since you've disabled the Right-Click to change code, I'm guessing it's in eModeWalkto - that's the default mode, being mode 0, so unless you've changed it yourself somewhere that's what it'll be. And like I said:
QuoteeModeWalkto doesn't trigger the 'Any click' interaction.

What you'll need to do is edit the on_mouse_click function to process eModeWalkto if the mouse is clicked on nothing, and some other mode if it's a Character/Object/Hotspot. Something like:
Code: ags

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) {
  // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) {
    // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick (mouse.x, mouse.y, eModeWalkto);
    else ProcessClick(mouse.x, mouse.y, eModeInteract);
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE

(Don't worry that it says eModeInteract - it'll still trigger the 'Any click' interaction. However, youmight as well put the interactions in 'Interact with', anyway, it makes the next bit easier.)

The other thing you're likely to want is Inventory interactions (using Items on a Character/Object/Hotspot). In that case, try editing the eMouseLeft condition to:
Code: ags

  else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick (mouse.x, mouse.y, eModeWalkto);
    else if (mouse.Mode == eModeUseinv) {
      ProcessClick (mouse.x, mouse.y, eModeUseinv);
      mouse.Mode = eModeWalkto;
    }
    else ProcessClick(mouse.x, mouse.y, eModeInteract);
  }

This way, if you've got an active Inventory item, it'll run the interaction for that item (if any), then change the mode back to eModeWalkto.
I know what you're thinking ... Don't think that.

Darkmaster400

#6
Thanks, this is great..Ã,  ;D

Okay I am sorry if I am too much trouble but I now know a little GUI codeing also..
I changed some guis and maybe now I can make the GUI seen in Monkey Island 1 and 2..

Is there any code triggering "Look" for example when clicking a GUI button??
This would be great..

EDIT: Now I noticed, if a unexperienced coder like me will steal code from a template, he will get several errors..  :-\   ;)

Regards,

---
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Khris

Emulating a fully functional MI-GUI is pretty much work, that's why there's a template.
If you really want to do your own, use a global variable that stores the verb of the last verb button clicked on, then use if-else if-else if... in the "interact with ..."-interaction to react accordingly.

Darkmaster400

#8
Aha, it sounds like alot of work too, I may stick to the templatesÃ,  ;)

EDIT: Im trying this code:

else if (button == eMouseLeft) {
    if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) ProcessClick (mouse.x, mouse.y, eModeWalkto);
    else if (mouse.Mode == eModeUseinv) {
      ProcessClick (mouse.x, mouse.y, eModeUseinv);
      mouse.Mode == eModeWalkto;
    }
    else ProcessClick(mouse.x, mouse.y, eModeInteract);
  }

But it gives me a error saying Error(line 64) PE04: Parse error at 'Mouse'
In Global Script.

And on line 64 I have this code:

      Mouse.Mode == eModeWalkto;


Regards,

---
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

#9
Sorry, that's what I get for typing too fast and not checking ...
It should be :
mouse.Mode = eModeWalkto;

(only one '=' is used to change variables, two '==' is for checking them, as in the if... lines).

I think the standard MI GUI uses all the modes, they just have the same cursor graphic. That way, you can have a GUI Button change the mode either by setting up it's Script to change to mode (e.g. mouse.Mode = eModeLookat;), or by setting it's 'Left click' property (on the floating 'Properties' pane) to 'Set cursor mode', and 'New mode number' to the mode you want. To emulate different modes while only using one you'll need to use a variable, as Khris said - but that seems like a needless complex way to achieve something that can be done with AGS default settings.

But Khris is right - if you want a fully functioning MI-GUI, you're probably better sticking with the existing templates, at least untill you're a lot more familiar with AGS coding.
I know what you're thinking ... Don't think that.

Darkmaster400

#10
Yeah, it fixed it but now I get another error on line 72 in Global Script.
The code is:

function interface_click(int interface, int button) {
// This function is obsolete, from 2.62 and earlier versions.
RestoreGameDialog();
}

The error was somelike:
Nested functions not supported (you may have forgotten a closing brace).

I checked and I dunno if I have forgot it, please, if you find it can you tell me where I shall
put it in?

EDIT: I found it now..

Regards,
---
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

That error means you've missed out a closing brace (}) BEFORE the line it mentions. Check the function before interface_click in the Global Script - it's likely to be on_mouse_click, given the line number, so it's possible you deleted the } pasting in the new code.
You can use Ctrl-B to match opening braces to closing ones, start at the beginning and work your way through till you find it. If you can't find anything, post everything before interface_click.

Two other things:
First off, interface_click is obsolete, as it says in that bit you posted. There ARE a few reasons you might still use it, but mostly you should stick with the individual GUI Control functions. Secondly, what are you trying to do with it? As it is, any button you press on any GUI will run RestoreGameDialog(), which I don't think you want.
I know what you're thinking ... Don't think that.

Darkmaster400

No worries, I fixed it now..
But one other question not related to the topic subject,
how do you use a invetory item with an hotspot?

Regards,
---
Games Process :
---------------------
Mick Fitz Episode 1 :

Story : |----------| 0 %
Graphics : |----------| 10 %
Sound/Music : |---------| 10 %
Scripting : |----------| 0 %

----------------------------------------

Ashen

On the interactions list (along with 'Any click', etc) there should be a 'Use Inventory on' interaction Code in there will be executed when an Item is used on it.
See also the BFAQ: Using a specific inventory item to trigger an action.

Are you having some problem with this (e.g. due to the coding changes), or have you just not read the manual and BFAQ?

(I deleted the other thread you started since you'd already posted here. Just have a little patience - you can't always expect immediate replies.)
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk