1
Beginners' Technical Questions / [solved] new left/right click infterface
« on: 12 Apr 2011, 18:09 »
hello there,
this is my first day i am using ags and i have been doing a lot of things today in customizing my own adventure, so far been finding out how to create own gui's (even text gui's), remove the text background, make an outlined text that is only used in speech but not in the menus, and recoded some minor stuff that i didn't like (added escape key option for inventory), done a transparent inventory with only 2 options and created own alpha channel graphics (i guess i can only use 1 colour as transparent, not really use an alpha channel so i could use anti-aliased sprites around the edges of the objects ?)
now i have found out how to use eMode for the mouse clicks.
what i want to do is : left click does walking AND using objects (and inventory objects), right click does look.
i implemented that already, but all i am missing is a trigger that tells me, if the cursor is on a usable object or useable hotspot, so i can set the mouse.mode to interact, else i would set the mouse.mode to walk.
here is my script so far:
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) { // LEFT MOUSE BUTTON
if (CURSOR ON A USABLE OBJECT OR HOTSPOT) {
if (player.ActiveInventory!=null){ // IF INVENTORY OBJECT IS SELECTED
mouse.Mode=eModeUseinv; // SELECT USE INVENTORY OBJECT MODE
}
else {
mouse.Mode=eModeInteract; // ELSE SELECT INTERACT MODE
}
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
else {
mouse.Mode=eModeWalkto; // IF CURSOR IS ON NO OBJECT SELECT WALK MODE
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
}
else if (button == eMouseRight){
mouse.Mode=eModeLookat; // SELECT LOOK AT MODE
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
}
i have been searching the forum and looking at faqs and variables, but couldn't find anything specific to this.
i could of course download an existing left/right mod, but i looked at the existing one and it only makes use of the lookat feature together with walk mode, that is available to all objects and hotspots, so i couldn't find the trigger i am looking for in there.
the trigger is this line in the beginning - if (CURSOR ON A USABLE OBJECT OR HOTSPOT) -
if there is no function for this (like checking mouse.x and mouse.y for objects 0 to 99 beeing there in that room or something), would there be another way to do this ?
this is my first day i am using ags and i have been doing a lot of things today in customizing my own adventure, so far been finding out how to create own gui's (even text gui's), remove the text background, make an outlined text that is only used in speech but not in the menus, and recoded some minor stuff that i didn't like (added escape key option for inventory), done a transparent inventory with only 2 options and created own alpha channel graphics (i guess i can only use 1 colour as transparent, not really use an alpha channel so i could use anti-aliased sprites around the edges of the objects ?)
now i have found out how to use eMode for the mouse clicks.
what i want to do is : left click does walking AND using objects (and inventory objects), right click does look.
i implemented that already, but all i am missing is a trigger that tells me, if the cursor is on a usable object or useable hotspot, so i can set the mouse.mode to interact, else i would set the mouse.mode to walk.
here is my script so far:
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) { // LEFT MOUSE BUTTON
if (CURSOR ON A USABLE OBJECT OR HOTSPOT) {
if (player.ActiveInventory!=null){ // IF INVENTORY OBJECT IS SELECTED
mouse.Mode=eModeUseinv; // SELECT USE INVENTORY OBJECT MODE
}
else {
mouse.Mode=eModeInteract; // ELSE SELECT INTERACT MODE
}
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
else {
mouse.Mode=eModeWalkto; // IF CURSOR IS ON NO OBJECT SELECT WALK MODE
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
}
else if (button == eMouseRight){
mouse.Mode=eModeLookat; // SELECT LOOK AT MODE
ProcessClick(mouse.x, mouse.y, mouse.Mode); // DO LEFT CLICK WITH SELECTED MOUSE MODE
}
}
i have been searching the forum and looking at faqs and variables, but couldn't find anything specific to this.
i could of course download an existing left/right mod, but i looked at the existing one and it only makes use of the lookat feature together with walk mode, that is available to all objects and hotspots, so i couldn't find the trigger i am looking for in there.
the trigger is this line in the beginning - if (CURSOR ON A USABLE OBJECT OR HOTSPOT) -
if there is no function for this (like checking mouse.x and mouse.y for objects 0 to 99 beeing there in that room or something), would there be another way to do this ?