Disabling Cursors

Started by Sylvr, Sun 10/03/2013 01:06:41

Previous topic - Next topic

Sylvr

Well hey there again you guys since forever. :D I'm starting over. My daycare kids and I are working on a game, and of course I get all the scripting work. :)

Can someone please tell me what I'm doing wrong here? This is for the intro screen, where buttons are hotspots and everything is a walk-behind. I'd like to have all cursor modes except Select (aka Usermode1)--or I guess Pointer would work except it didn't when I tried on my own so I just renamed an extra sample cursor. ANYWAY, when I run what I have, the walkmode is the only one that shows up, and even then it doesn't seem to affect the hotspots, which are ANYCLICKS.

function room_RepExec()
{
  mouse.DisableMode(eModeInteract);
  mouse.DisableMode(eModeLookat);
  mouse.DisableMode(eModePickup);
  mouse.DisableMode(eModeTalkto);
  mouse.DisableMode(eModeUseinv);
  mouse.DisableMode(eModeWalkto);
  mouse.DisableMode(eModeUsermode2);
  mouse.EnableMode(eModeSelect);
  gStatusline.Visible = false;
  gIconbar.Visible = false;
}

Thanks!
| Ben304: "Peeing is a beautiful thing, Sylvr" |

Demicrusaius

I'm not totally sure I understand what you're trying to do, but let me take a few guesses.
"Any Click" on a hotspot means any click except for walk mode, I'm pretty sure.
When making your intro screen, don't use an intro screen room, use a gui. You'd have more success with using gui buttons instead of hotspots, I think.
Instead of using function room_RepExec() try function game_start() if you're trying to make a title screen. This will only happen once. Or if you're trying to do an intro cutscene inside a room then try function room_Load().
It is better to light one small candle than to curse the darkness.

Sylvr

Well the thing is that it's a hand-drawn screen done by one of my kids. Not sure how to turn that into a GUI. .....actually I'm not sure what to do with GUIs at all. :$

And I wasn't aiming to use the walk function to activate the buttons, it's just the only mode that's coming up. (I hope that helps to clarify.)
| Ben304: "Peeing is a beautiful thing, Sylvr" |

Khris

#3
I'd add the room's before fadein event / room_Load function.

Code: ags
// in room load
  mouse.Mode = eModeSelect;
  gStatusline.Visible = false;
  gIconbar.Visible = false;

// add this outside other functions:
function on_mouse_click(MouseButton button) {
  if (button != eMouseLeft) ClaimEvent();  // Disable everything except left clicks in this room
}


(Remove the code you have.)

Sylvr

Thanks so much Khris! Now... a total noob question I know-- "button" is an undefined symbol error. When I said above "activate the buttons", I meant hotspots disguised as buttons(hBegin, hRestore, hCredits, etc.). So might it be

if (hBegin != eMouseLeft)    ? I know I'm missing something after hHotspot.
| Ben304: "Peeing is a beautiful thing, Sylvr" |

Khris

#5
Sorry, I made a mistake; I forgot to include the parameter. I changed line 7 in the code, now it should work.

My code changes the current mode to eModeSelect. (I'd use eModePointer for this, but it looks like you already created that mode and it should trigger AnyClick events, so it's fine.)
And it disables right clicks and the mouse wheel, so the user can't change the mouse mode.

I think your code didn't work because AGS doesn't change the current mode if it is disabled. Whether a mode is enabled or not only comes into play when you call mouse.SelectNextMode() I guess, which is the default handling of right clicks.

Come to think of it, I guess the keyboard shortcuts are still active though.

Sylvr

#6
Code: ags
It is so nice to have working code. :D Thanks again.

I guess the keyboard side wouldn't quite be necessary, but for completeness and my practice I'd like to throw it in. Also, F5 doesn't work on the menu screen, so...cool? 

So what is the keyboard equivalent for "on_mouse_click", etc? Came up with

[code=]function on_key_press(KeyboardMovement key){
  if (key = 27) ClaimEvent();
} 


but it came back with struct cannot be passed as a parameter, even though KeyboardMovement is in the same kind of blue as MouseButton, which I took to mean that I had to come up with a different name for KeyboardMovement. However, something like KeyPress returns a parse error.

| Ben304: "Peeing is a beautiful thing, Sylvr" |

Khris

KeyboardMovement is a struct defined in the KeyboardMovement module.

You could have looked up the line, it's right there in the global script, too:
Code: ags
function on_key_press(eKeyCode key) {


As for the content, to compare two values, you need ==, not =.

I'd go with:
Code: ags
function on_key_press(eKeyCode key) {
  ClaimEvent();
  if (key == eKeyEscape) QuitGame(0);
  if (key == eKeyF7) show_restore_game_dialog();
}

Sylvr

#8
Thanks. :)

All the stupids I feel. The trouble is I am just not sure what to look for. I know what I want the code to say, I'm just missing the vocabulary words.

EDIT: another parse error at eKeyCode?
| Ben304: "Peeing is a beautiful thing, Sylvr" |

SMF spam blocked by CleanTalk