I'm really sorry if this thread allready exists, but i really need help(really).
I want to make cursor on which will be displayed Hotspot or object name when it moves over hotspot/object, such as used in 7 days a sceptic. Thnx.
Labelname.SetText("@OVERHOTSPOT@");
"@OVERHOTSPOT@" is replaced with the object/hotspot/character name that the mouse is over. And if you want it to follow the mouse, you could just add (in rep_ex):
if (mouse.Mode == eModeHotspot) {
Labelname.X = mouse.X + 5;
Labelname.Y = mouse.Y + 5;
Labelname.Visible = true;
}
else Labelname.Visible = false;
Of course that's mostly just some pseudo-code, but I think you should be able to get the drift of it.
I use:
----------------------------------------------------------------------------------------------------
int Over;string Name;int CharId, Direction, dx, dy;
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// put anything you want to happen every game cycle here
if (IsOverlayValid(Over)){
GetLocationName(mouse.x,mouse.y,Name);
SetTextOverlay(Over,mouse.x-25,mouse.y-18,100,1,15,Name);}
//mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color
#sectionstart on_event // DO NOT EDIT OR REMOVE THIS LINE
function on_event (int event,int data) {
if (event==ENTER_ROOM) {
GetLocationName (mouse.x,mouse.y,Name);
Over=CreateTextOverlay(mouse.x-25,mouse.y-18,100,1,15,Name);}
//mouse.x/mouse.y=position, 100=width, 1=?font?, 15=color
else if (event==LEAVE_ROOM) {
RemoveOverlay (Over);}
//Needs additional script to remove the overlay during the actual interaction.
}
------------------------------------------------------------------------------------------------------
A bit more complicated, but it gets the job done :)
Thanks. So, I just copy this to global script or what?
Well it's a lot easier to just use a label.
Quote from: monkey_05_06 on Wed 06/07/2005 19:34:04
Well it's a lot easier to just use a label.
Yes it is, but there are some problems with it. When blocking event starts, label does not dissapear. With overlay you can make it dissapear on blocking actions.
Uhm, Guys? I still have one question. Where should I put this lines? In global script? I really am a beginner, so sorry for beeing so... Can't think of the word, but you get what I mean.
Yes the global script. The first line goes way at the top, the second chunk under repeatedly_execute and the last bit under sectionstart_on_event
Do please note the
function repeatedly_execute() {
// put anything you want to happen every game cycle here
and the
function on_event (int event,int data) {
Which should already be in the script.
Actually I don't think on_event is in the global script by default is it? If not you can consult the manual on how to create it. Unless of course I'm just completely wrong.
Yeah. I've copyed it to global script just like (where) you said, but there's always some error messages I don't wanna. Could you explain it to me how exactly it's suposed to be (yeah, I know, I'm dumb.)
Quote from: guybrush on Sun 10/07/2005 19:22:27
Yeah. I've copyed it to global script just like (where) you said, but there's always some error messages I don't wanna. Could you explain it to me how exactly it's suposed to be (yeah, I know, I'm dumb.)
What error message? Check your braces ([{...
HOLY COW! It works. I just tried again and it works perfectly. Thank both of you, It looks perfect! ohhh i'm so cool.
OK, now I have a new problem. Is there some script function that will remove that hotspot name after entering a room? Because I have some guys in the car, in which the player can't move or anything, just talk. And there's a big characher name next to him, guess that's because cursor is on him when the room loads. Soo?
Everything is quite good with your all that and all. That. But now i need some kind of function which will remove hotspot name, because it stays, even in the cutscene. And it gets mixed up with character text, so you know.
Which of the two suggested solutions are you using?
If you use largopredator's overlay, doesn't
RemoveOverlay(Over);
work?
Quote from: strazer on Thu 21/07/2005 01:26:29
Which of the two suggested solutions are you using?
If you use largopredator's overlay, doesn't
Ã, RemoveOverlay(Over);
work?
Yes, largopredator's.
Don't know, I didn't try. Is this a function for global script?
No, put it in the "Player enters screen (before fadein)" interaction of the room ("i" button -> "Player enters..." -> "Run script" -> "Edit script...").
OK, but is there a global script function which will remove the name automaticly when "Wait" is on? I mean, so i don't have to turn it off every time player enters the room. If not, thanks anyway.
I still haven't figured it out completely, but what might help you along is this script:
-------------------------------------------------------------------------------------------------------
#sectionstart on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int 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 == LEFT) {
RemoveOverlay (Over);
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
GetLocationName (mouse.x,mouse.y,Name);
Over=CreateTextOverlay(mouse.x-25,mouse.y-18,100,1,15,Name);
}
-------------------------------------------------------------------------------------------------------
The italic lines have to be added, the rest should already be there.
It's not exactly what you meant, but it's very useful during interactions. I've seen this only fixes the issue(aka removes the overlay) for hotspots that rely on room messages. With objects, characters, global messages and scripted interactions it doesn't work. I'm still working on it...
What Strazer suggested should help your particular problem though. Just remember to re-enable the overlay once the sequence is finished, like I did in the script above.
Or try this:
function repeatedly_execute() {
if (IsOverlayValid(Over)) {
if (IsInterfaceEnabled()) GetLocationName(mouse.x, mouse.y, Name);
else StrCopy(Name, "");
SetTextOverlay(Over, mouse.x-25, mouse.y-18, 100, 1, 15, Name);
}
}
Quote from: strazer on Sat 23/07/2005 16:51:13
Or try this:
function repeatedly_execute() {
Ã, if (IsOverlayValid(Over)) {
Ã, Ã, if (IsInterfaceEnabled()) GetLocationName(mouse.x, mouse.y, Name);
Ã, Ã, else StrCopy(Name, "");
Ã, Ã, SetTextOverlay(Over, mouse.x-25, mouse.y-18, 100, 1, 15, Name);
Ã, }
}
Hmm, I've tried that, but I'm afraid it doesn't work.
Largopredator, I'll try yours too.
Didn't work for me either. I've tried different versions, even checking the getmousecursor() == 7. No dice.
Guess I'll just have to add the extra lines in every script in my game aswell. It's the only way to disable the overlay during every interaction. That or rescripting the entire thing some other way.
Thnx a lot guys! You've been really helpful.
Oh yeah, sorry, the repeatedly_execute function doesn't run when the game is blocked, only repeatedly_execute_always does.
So just try changing
function repeatedly_execute() {
to
function repeatedly_execute_always() {
with the _always addition, the overlay only updates when you switch cursor mode. It doesn't follow the mouse anymore. It does remove it during interactions though.
Strange, works great for me together with the code from your first post.