EDIT: Shoot! I'm sorry but I've put this topic in the wrong section... Could someone mightier than me move it to the Beginners' Technical Questions?
Hi,
Am I right to think that AGS handles interactions with hotspots and objects differently? I've got one function which is called when the player interacts with either a hotspot or an object. To my surprise, when I click the object all instructions in the function are called in order but when clicking the hotspot it's not the case. First the walking function is triggered and then all the rest. I'm guessing it's got something to do with blocking mode? Could anyone point me in the right direction how to work around it?
I'm using a clean template in version 3.5.0 P2.
//my function called when interacting with both the object and the hotspot
function cf_handle_elevator_interaction()
{
if(!elevatorDoorsOpen)
{
hijackOverMouse = true;
sayTextAsTypingMachine("I need to get to floor one. I'm afraid though that the sysetm might have been messed up again.", cLeszek);
cLeszek.WalkStraight(528, 270, eBlock);
oElevatorDoors.SetView(4, 0, 0);
oElevatorDoors.Animate(0, 3, eOnce, eNoBlock, eForwards);
elevatorDoorsOpen = true;
hijackOverMouse = false;
}
}
//event handlers
function hElevatorButton_Interact()
{
cf_handle_elevator_interaction();
}
function oElevatorDoors_Interact()
{
cf_handle_elevator_interaction();
}
Ok, I've also noticed that when I removed the walk() function from my event handler the character was still walking up to the hotspot (only hotspot). So I removed walkTo coordinates of the hotspot and now everything works as intended. Is there a way to disable the automatic walking to the hotspots even if I want to specify walkTo points?
I think there's a setting on the game settings to turn it off. Can't check atm.
I looked there even before but the only one I saw was "Automatically walk to hotspots in Look mode". But by default it was set to false and I'm not even using the look mode so I'm guessing it's not the one I'm after :)
Quote from: Pogwizd on Mon 22/06/2020 13:09:01
I looked there even before but the only one I saw was "Automatically walk to hotspots in Look mode". But by default it was set to false and I'm not even using the look mode so I'm guessing it's not the one I'm after :)
Could you post your on_mouse_click function? Also, do you use any modules made by other people?
(you said you are using "clean template", do you mean Empty Game?)
Yes, I meant an empty game.
Right now, not much is going on in the on_mouse_click():
function on_mouse_click(MouseButton button)
{
if (IsGamePaused()){}
else if (button == eMouseLeft)
Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
}
For now, I'm switching between mouse modes using keys W and I (walk, interact - I'm not planning on using other modes).
Also, I am not using anyone else's modules but I created my own script with an intention to move there all my custom functions. At the moment, there is only one function and it's not affecting on_mouse_click() (so I think).
That's my script if you want to have a look at it too:
// new module script
function sayTextAsTypingMachine(String currentText, Character *currentCharacter)
{
isTextBeingTyped = true;
hijackOverMouse = true;
int speechBubbleX = currentCharacter.x - 10;
int speechBubbleY = 50;
DynamicSprite* speechBubbleSprite = DynamicSprite.CreateFromExistingSprite(35);
DynamicSprite* speechBubbleBackground = DynamicSprite.CreateFromBackground(0, speechBubbleX, speechBubbleY, speechBubbleSprite.Width, speechBubbleSprite.Height);
DrawingSurface *speechBubbleSurface = Room.GetDrawingSurfaceForBackground();
DrawingSurface *backgroundSurface = Room.GetDrawingSurfaceForBackground();
//draw speech bubble
speechBubbleSurface.DrawImage(currentCharacter.x-10, 50, speechBubbleSprite.Graphic);
speechBubbleSurface.Release();
speechBubbleSprite.Delete();
//type the text out
int length = currentText.Length;
for(int index = 0; index<=length;index++)
{
String output = String.Format("%s: %s", currentCharacter.Name, currentText.Truncate(index));
lblTextHolder.Text = output ;
//if a clicked has been detected, show all the text
if(showAllText)
{
output = String.Format("%s: %s", currentCharacter.Name, currentText);
lblTextHolder.Text = output ;
break;
}
Wait(2);
}
//reset globals handling typing
isTextBeingTyped = false;
showAllText = false;
WaitMouseKey(100);
//redraw the background from underneath the speech bubble
backgroundSurface.DrawImage(speechBubbleX, speechBubbleY, speechBubbleBackground.Graphic);
backgroundSurface.Release();
speechBubbleBackground.Delete();
//clear text box
lblTextHolder.Text = "";
//release action label
hijackOverMouse = false;
}
Hi,
I don't mean to bump the topic but I'd like to know if the automatic walking up to the hotspots is something only I'm experiencing or is it an option that can be disabled?