Interacting with hotspot and objects through scripts using Tumbleweed Template [S]

Started by Nahuel, Mon 19/09/2022 13:25:10

Previous topic - Next topic

Nahuel

Hi there everyone, I'm trying to avoid using scripts to run cutscences where the character CAN actually use the objects, and I'm facing some issues, finding some interesting topics in the forum suggests using Room.RunInteraction but the problem with that is that with the Verbs it's not doing anything

It was working when I added 2 time the same code, which was of course replicated twice
I'm also using relative coords. At the beginning I was not taking that into account. But now I can see when using the same action twice

Code: ags
  Verbs.SetAction(eGA_Close);
  Room.ProcessClick(104, 90, eModeInteract);

I also did something palliative which interacts directly with the mouse but, It's not clean...
Code: ags
    mouse.SetPosition(227, 51);
    Verbs.SetAction(eGA_Close);
    mouse.Click(eMouseLeft);mouse.Click(eMouseLeft);

Any help will be welcome! Thanks!
Life isn't a game. Let's develop a life-like-game.

Khris

You can call the function directly, like this:
Code: ags
  Verbs.SetAction(eGA_PickUp);
  oBlueCup_AnyClick();

Nahuel

Quote from: Khris on Tue 20/09/2022 11:54:53You can call the function directly, like this:
Code: ags
  Verbs.SetAction(eGA_PickUp);
  oBlueCup_AnyClick();


Will check that then! Thanks @Khris
Life isn't a game. Let's develop a life-like-game.

Nahuel

That didn't work  :undecided:  unfortunately
The mouse actions is correctly set but nothing happens
Life isn't a game. Let's develop a life-like-game.

Khris

It works fine for me, can you show the room script? Or the relevant parts?

Nahuel

Quote from: Khris on Tue 20/09/2022 22:30:21It works fine for me, can you show the room script? Or the relevant parts?

Sure!  Here's the actual real example

A fridge is opened and the character after moving out from a region should close it (but because the complexity of the logic to close it and reopen again makes the "automatic" action easy to be picked instead of coding again or reusing a function etc

Code: ags
function region2_WalksOnto()
{
  if ( hOpenFridge.Enabled ) {
    StartCutscene(eSkipScriptOnly);
    
    player.StopMoving();
    mouse.Visible = false;
    player.FaceDirection(eDirectionDown);
    player.Say("Hey! Cierra la heladera!");
    // mouse.SetPosition(227, 51);
    Verbs.SetAction(eGA_Close);
    hOpenFridge_AnyClick();
    EndCutscene();
    mouse.Visible = true;
  }
}

Code: ags
function hOpenFridge_AnyClick()
{
  if ( Verbs.UsedAction(eGA_Close) || Verbs.UsedAction(eGA_Push) ){
    player.Walk(544, 69, eBlock, eWalkableAreas); // goes to the extreme part of the fridge
    player.FaceDirection(eDirectionUp);
    player.AnimatePickUp(eBackMiddle); // does an animation like middle movement 
    aFridge_close.Play();
    oOpenFridge.Visible = false;
    InteriorFridge(false);  // this functions disables all objects
    player.Walk(518, 69, eBlock, eWalkableAreas); goes back to the middle of the fridge
    player.FaceDirection(eDirectionDown);
  }
}

When the function is done, the only thing that happens is that the cursor is set to Close and nothing more is done. Will be posting a gif


Life isn't a game. Let's develop a life-like-game.

Khris

You're right; Verbs.SetAction changes verbsData.global_action but not verbsData.used_action.
I missed that I was getting the response for looking at the cup instead of picking it up.

It's possible to extend the Tumbleweed script to allow triggering certain actions but unless you need to do that lots of times during the game it's probably easier to just move the fridge closing code into a separate function and call it from both places.

Nahuel

I see, thanks @Khris, no I won't be using that lots of times, just a few, and I think with the position of the mouse pointer and the click action can be done, and even using left click for defaulted actions.

Thanks a lot for taking the time to respond and help me.
Life isn't a game. Let's develop a life-like-game.

SMF spam blocked by CleanTalk