Automatic cursor switching

Started by Ultra Magnus, Fri 29/08/2008 10:50:48

Previous topic - Next topic

Ultra Magnus

Hey.
I'm sure this is going to end up being blindingly obvious, but I'm stuck.

In global I have a LucasartsStatus function, including...
Code: ags

if (mouse.Mode==eModeWalkto) {
  buf = String.Format("Walk to %s", name);
}


In multiple rooms I have something along the lines of...
Code: ags

function hZiggyshouse_MouseMove()
{
 mouse.SaveCursorUntilItLeaves();
 mouse.Mode = eModeWalkto;
 mouse.ChangeModeGraphic(eModeWalkto, 1);
}


This results in the cursor changing and the status line reading Walk to Ziggy's house.

In another room I have...
Code: ags

function hTownhall_MouseMove()
{
 mouse.SaveCursorUntilItLeaves();
 mouse.Mode = eModeWalkto;
 mouse.ChangeModeGraphic(eModeWalkto, 1);
}


With this one, the cursor doesn't change and the status line just reads the town hall (name of the hotspot) without prefacing it with anything.

I've double and triple checked, and I didn't forget to declare the MouseMove function in the event menu thing.

That is the exact same code, isn't it?
So why would it work in all rooms with all hotspots except this particular one?

Thanks in advance for any help.

(version 3.0)
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Gilbert

Hmmm I think you might have checked this already, but I'll just ask in case something is missing.

Are you sure the name of the function shown in the event section is indeed hTownhall_MouseMove? If it is not change that to match the name used in the script.

Khris

Btw, you can save yourself a lot of trouble by adding a custom property and setting it to "true" for walk-only hotspots, then adding appropriate code to the rep_ex.

Ultra Magnus

Quote from: Gilbot V7000a on Fri 29/08/2008 12:45:13
Are you sure the name of the function shown in the event section is indeed hTownhall_MouseMove?

Yeah, it is.



And when I click the [...] it takes me to the bit of script I posted above, like it's meant to.

Quote from: KhrisMUC on Fri 29/08/2008 18:06:35
Btw, you can save yourself a lot of trouble by adding a custom property and setting it to "true" for walk-only hotspots, then adding appropriate code to the rep_ex.

I hadn't thought of that. I'll give it a go.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Ultra Magnus

Okay, I tried doing a custom property instead and it still didn't work for that one hotspot.
Then I changed it from...

Code: ags
 mouse.Mode = eModeWalkto;
 mouse.ChangeModeGraphic(eModeWalkto, 1);


...to...

Code: ags
 mouse.Mode = eModeMoveto;
 mouse.ChangeModeGraphic(eModeMoveto, 1);


...and it works fine.
So it was apparently a problem with eModeWalkto, but then why would it work on all other hotspots in the game but this specific one?

Even though it's not an issue anymore, I'd still like to get this figured out in case it affects (or is related to something that will affect) the game in some other way.
I can always swap the code back to eModeWalkto to test theories.

Any thoughts?
Thanks.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Gilbert

I suspect that you might have disabled the "Walkto" mode in that room. try to check it.

Ultra Magnus

#6
You might be right, there.

There are three exit-point hotspots in that room.
Before, I had left and right as Moveto and Move(are)* (modes 8 and 9) and used Walkto (with changing cursor icon) for diagonals.
I just changed it so they all use Walkto (with different cursors), and they all (in that room) stopped working.

How might I have disabled that mode, though?
There's no other mention of mouse modes in the room yet, and I've tried entering from four different entry points to the same result, so it's not likely to be anything outside the room script, is it?

It now uses Lookat mode constantly in that room, despite the global rep_exec saying "Walkto if over an exit point, or Pointer if not", and no Lookat anywhere.


*this is supposed to be the letter 'r', as seen in the pic above, but was "automatically edited for txt-style spelling".


On a (tenuously) related note, now that I'm using the method Kris suggested, it changes mode when I hover over an exit point, but there is a brief delay (I'm assuming one cycle) in changing back when I move off again.
Example: if the hotspot leads to the Mayor's house, on mouseover it'll display "Walk to the Mayor's house", but when moving off it flashes "Walk to" before going blank again.
Is there any way to fix this? It's pretty annoying.

Thanks.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Ultra Magnus

#7
Sorry.
I'm a pain in the arse, I know. ::)

Anyway, forget the previous posts in this thread for now, because I just made it a whole lot worse and I don't know how.

Now none of the cursor switching/statusbar labelling is happening at all.
I'm just constantly stuck in Lookat mode regardless of what may or may not be under the mouse.

Could somebody please take a look at this and tell me where I've gone wrong?
Thanks in advance.


Global.ash:-
Code: ags
import String StatusOverride;
import String namestring;
import bool Usepoint;
import bool Talkpoint;
import bool Walkpoint[6];


Global.asc:-
Code: ags
function LucasartsStatus() {
	String buf, name;

	if (GUI.GetAtScreenXY(mouse.x, mouse.y)==null) {
		name = Game.GetLocationName(mouse.x, mouse.y);

    if (mouse.Mode==eModeMoveto) {
      buf = String.Format("Walk to %s", name);
    }
    else if (mouse.Mode==eModeTalkto) {
      buf = String.Format("Talk to %s", name);
    }
    else if (mouse.Mode==eModeInteract) {
      buf = String.Format("Use %s", name);
    }
    else if (mouse.Mode==eModeUseinv) {
      buf = String.Format("Use %s with %s", player.ActiveInventory.Name, name);
    }
    else if (mouse.Mode==eModeUseinv && Talkpoint==true) {
      buf = String.Format("Give %s to %s", player.ActiveInventory.Name, name);
    }
		else {
			buf = name;
		}
	}
	else { 
		buf = " ";
	}							
	gIconBarStatus.Text = buf; 

<snip>

if (StatusOverride!=null) gIconBarStatus.Text=StatusOverride;
}


  // REP_EXEC FUNCTIONS

function repeatedly_execute() {
  LucasartsStatus();
  
  if (player.ActiveInventory!=null) {
    if (GUI.GetAtScreenXY(mouse.x, mouse.y)==null) {
      if (Usepoint==true) mouse.Mode=eModeInteract;
      else if (Talkpoint==true) mouse.Mode=eModeTalkto;

      else if (Walkpoint[0]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto,  1);
        }
      else if (Walkpoint[1]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto, 4);
        }
      else if (Walkpoint[2]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto, 103);
        }
      else if (Walkpoint[3]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto,  105);
        }
      else if (Walkpoint[4]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto, 3);
        }
      else if (Walkpoint[5]==true) {
        mouse.Mode=eModeMoveto;
        mouse.ChangeModeGraphic(eModeMoveto, 5);
        }
      else {
        mouse.Mode=eModePointer;
        }
      }
    else {
      mouse.Mode=eModePointer;
      }
    }
  else {
    mouse.Mode=eModeUseinv;
    }

<snip>

}


Room:-
Code: ags
function room_RepExec()
{
  if (mouse.Mode!=eModeUseinv) {
    if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hMailbox)
      Usepoint=true;
      else Usepoint=false;
    if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hMailtube)
      Usepoint=true;
      else Usepoint=false;
    if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hLever) {
      Usepoint=true;
      StatusOverride="Pull the lever"; }
      else {
        Usepoint=false;
        StatusOverride=null; }
    if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hLeftedge)
      Walkpoint[0]=true;
      else Walkpoint[0]=false;
    if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hRightedge)
      Walkpoint[3]=true; 
      else Walkpoint[3]=false;
    }
}



My untrained eye really can't see why this shouldn't work.
(Different room to the one above, by the way. This one's the starting room.)

Also, when I open a GUI, the hotspots still register from behind it. I've searched around, and the most I can find is "just use if (GUI.GetAtScreenXY(mouse.x, mouse.y)==null)", but I've used that with both of the hotspot registering functions (mode switching and statusbar thingy), and it doesn't stop either of them happening (when they work at all, that is).

Also also, is there a quick and easy way of declaring all Walkpoints (0-5) false without having to do them all separately?

Any ideas?
Thanks heaps.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Ultra Magnus

I'll take that as a 'no', then.

Okay, no worries, I'll go back to doing it the long way round.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

SMF spam blocked by CleanTalk