SetButtonPic on mouseover?

Started by beaver, Sat 01/05/2004 21:56:11

Previous topic - Next topic

beaver

Ok, I know i can make a button pic change when the mouse goes over a hotspot, (and change back again by using another hotspot around it). and i can make a button pic change when the player stands on a region... but is there a way to make a button pic change when the mouse passes over a character?

thanks

Ishmael

Consult the manual on GetLocationType type functions...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

beaver

hmm, usefull, but what if the character was moving/moved to a different location?

Ishmael

check in repeadetly_execute if GetLocationType is nothing or GUI...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

beaver

ah i see, i was thinking it would only do it when the player was over the coordinates stated, but it relies on where u put the mouse.

thanks very muchly.

beaver

doh, that works nicely, only thing is i wanted the button to change to a different pic depending on what character it was over, not just any character. is that possible?

Ashen

Yeah, it's possible. you just have to add an extra layer of 'if..' coding, based on:
if (GetPlayerCharacter() == WHATEVER) {
   SetButtonPic(..., ...);
 }
I know what you're thinking ... Don't think that.

beaver

im not sure how to implement that... here is what i tried to do using it. but it just made the button change to the same sprite regardless of which character it was over (player or npc)

if (GetLocationType(mouse.x,mouse.y)== 2)
   SetButtonPic(INTY, 0, 1, 179);
   if (GetPlayerCharacter() == 0)
   SetButtonPic(INTY, 0, 1, 177);
   if (GetLocationType(mouse.x,mouse.y)==0)
   SetButtonPic(INTY, 0, 1, 175);

Ashen

My mistake - didn't read the question properly. Don't know what I was thinking.

You need it to look something like this:
if (GetLocationType(mouse.x,mouse.y)== 2) {
 if (GetCharacterAt(mouse.x, mouse.y) == 0) {
   SetButtonPic(INTY, 0, 1, 177);
 }
 else SetButtonPic(INTY, 0, 1, 179);
}
if (GetLocationType(mouse.x,mouse.y)==0)
SetButtonPic(INTY, 0, 1, 175);
I know what you're thinking ... Don't think that.

beaver

excellent, that works great.
thanks

beaver

#10
1 last thing, i take it you can only do it with a maximum of 2 characters?
oh, and can rolling over a button change the image on another button?


ignore that, i just found GetGUIObjectAt that should do it i think

Ashen

#11
No, you can do as many characteras as you like:

if (GetLocationType(mouse.x,mouse.y)== 2) {
 if (GetCharacterAt(mouse.x, mouse.y) == 0) {
   SetButtonPic(INTY, 0, 1, 177);
 }
 else if (GetCharacterAt(mouse.x, mouse.y) == 1) {
   SetButtonPic(INTY, 0, 1, 178);
 }
 else if (GetCharacterAt(mouse.x, mouse.y) == 2) {
   SetButtonPic(INTY, 0, 1, 180);
 }
 else SetButtonPic(INTY, 0, 1, 179);
}
and so on, using 'else if'. And:

if (GetGUIAt(mouse.x,mouse.y) == INTY) {
 if (GetGUIObjectAt(mouse.x,mouse.y) == 1) {
  SetButtonPic(INTY, 0, 1, 177);
 }
 else SetButtonPic(INTY, 0, 1, 179);
}
should change the object 0 image, when the mouse is over object 1. That's not tested though, so it may not work.

EDIT: was typing this when you re-posted. Hope it helps anyway.
I know what you're thinking ... Don't think that.

beaver

hm, something is a bit wrong with it, says parse error unexpected if. would that just be how ive put the script in though?

Ashen

What line is the 'unexpected if' on? Can you show the code around it?
I know what you're thinking ... Don't think that.

beaver

if (GetLocationType(mouse.x,mouse.y)== 2) {
if (GetCharacterAt(mouse.x, mouse.y) == 0) {
SetButtonPic(INTY, 0, 1, 177);
}
else SetButtonPic(INTY, 0, 1, 179);
}
if (GetLocationType(mouse.x,mouse.y)==0)
SetButtonPic(INTY, 0, 1, 175);  
}
if (GetGUIAt(mouse.x,mouse.y) == INTY) {          <-------------- this one
if (GetGUIObjectAt(mouse.x,mouse.y) == 1) {
SetButtonPic(INTY, 0, 1, 177);
}
else SetButtonPic(INTY, 0, 1, 179);
}

i dont think its your code, i think ive just screwed up =)

Ashen

Try:
if (GetLocationType(mouse.x,mouse.y)== 2) {
 if (GetCharacterAt(mouse.x, mouse.y) == 0) {
   SetButtonPic(INTY, 0, 1, 177);
 }
 else SetButtonPic(INTY, 0, 1, 179);
}
if (GetLocationType(mouse.x,mouse.y)==0) { //<---- this runs on GUIs
 if (GetGUIAt(mouse.x,mouse.y) == INTY) {
   if (GetGUIObjectAt(mouse.x,mouse.y) == 1) {
     SetButtonPic(INTY, 0, 1, 177);
   }
 else SetButtonPic(INTY, 0, 1, 179);
}
else SetButtonPic(INTY, 0, 1, 175);
}

As it was, there were two bits of script telling it what to do over a GUI (GetLocationType == 0, and GetGuiAt), which might've confused it, especially since this is the line that returned the error.
I know what you're thinking ... Don't think that.

beaver

yeh that works great. you too kind.
only thing was i had to add another closing bracket at the end of the script

SMF spam blocked by CleanTalk