[SOLVED]Room does not show opacity layer

Started by Racoon, Thu 16/04/2020 18:33:46

Previous topic - Next topic

Racoon

Well the bad thing is, it does not work   :-D
It still does not change the description into anything else after the bool turns true.
I even tried abother approach like this
Code: ags
if (Hotspot.GetAtScreenXY(237, 172) ==hotspot[26]) {lblDescription.Text = "Maat"; } 

to see if it would turn out any different, but it does not.
My idea is, that maybe lblDescription.Text = Game.GetLocationName(mouse.x, mouse.y); can not be overriden. But I don´t know.


Matti

That's weird, this should definitely work.

Are you really sure that MaatLooked is true? Just could check by putting this in the room's rep exe:
Code: ags

if (MaatLooked) lblDescription.Text = "true";

Khris

Add the RepExec event and function to the room.
Then put this inside the function:
Code: ags
  if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hMaat && MaatLooked) lblDescription.Text = "Maat";


As for the inventory code, I assume you're using two-click handling? My code should enable you to pick up items by clicking them with eModeInteract, but I'm just guessing here. Are you using the BASS template?

Racoon

I did all that, but it still just shows the usual description. The bool was true, I checked that with DisplayText, because this 
Code: ags
if (MaatLooked) lblDescription.Text = "true";
would not work either. I don´t know if its even worth the effort at this point, but thanks for putting up with me.

I use the Sierra Style template. By two click you mean left for ineract and right for look?

Cassiebsg

for 2) there's also the alternative of using custom  properties, use a String and type the description in there, point the "label" to read from it, and then change the custom property at will.

this way you avoid having to create extra ifs and checks.
There are those who believe that life here began out there...

Crimson Wizard

@Racoon, are you sure this lblDescription.Text is not set anywhere else in code?

Khris

The Sierra template? Yet you said
Quote from: Racoon on Mon 20/04/2020 10:05:39
3) When I have an item selected in the inventory window I would like to deselect it by right mouse click like it does outside the inventory.
That's not how the Sierra template works afaik. Right-clicking outside the inventory should change the cursor mode to eModeWalkto.

Cassiebsg

Yes, sounds more like you're using the BASS template. Check the header of GlobalScript.
There are those who believe that life here began out there...

Racoon

I can´t find any clue in the header of the Global script. But I think I am using Sierra style. I disabled eModeWalkto because its a first person escape room game. So it changes into "Look" and does not actually deselect the piece and I just interpreted that as deselecting because I never went through all modes to see the item again. Sorry, that my description was misleading!

And I will try one more time to gel the label to work like I want to, but then I will just leave it as it is. I think it will be ok even without it.

Khris

If you're using the Sierra template, you can try this:
Code: ags
  else if (button == eMouseLeftInv) {
    // interact with item to grab it
    if (mouse.Mode == eModeInteract) player.ActiveInventory = inventory[game.inv_activated];
   // else process click
    else inventory[game.inv_activated].RunInteraction(mouse.Mode);
  }
  else if (button == eMouseRightInv) on_mouse_click(eMouseRight); // redirect to standard right click 

Racoon

I tried your code, but it if I add it after the eMouseRight section,then I can not pick up or look at ineventoryitems. If I put the code to the beginning of the on_mouse_click function, it works so far, that I can pick up an item and look at it again, but it still does not change with right click. I also double checked that I put Override built in inventory window click handling to true.

Khris

Besides a proper sequence of  if ... else if ... else if ... [...] ... else, it shouldn't matter whether you put that code at the start or near the bottom, which suggests that there's a brackets / nesting issue.
For instance if you accidentally put my code inside the eMouseRight block, it will never get called at all.
Can you post the full on_mouse_click you're using?

Racoon

This is what it looks like if I put it where I think you meant for me to put it:

Code: ags
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) {
    Room.ProcessClick(mouse.x, mouse.y, mouse.Mode );
  }
  else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
    mouse.SelectNextMode();
  } 
  else if (button == eMouseLeftInv) {
// interact with item to grab it
  if (mouse.Mode == eModeInteract) player.ActiveInventory = inventory[game.inv_activated];
// else process click
  else inventory[game.inv_activated].RunInteraction(mouse.Mode);
      }
  else if (button == eMouseRightInv) on_mouse_click(eMouseRight); // redirect to standard right click 
  else if (button == eMouseMiddle) { 
    // Middle-button-click, default make character walk to clicked area (a little shortcut)
    // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
    // leave our options open - what if you have a special script triggered
    // on "walking" mode?
    Room.ProcessClick(mouse.x, mouse.y, eModeWalkto); 
  }
  else if (button == eMouseWheelNorth) { 
    // Mouse-wheel up, cycle cursors 
    // If mode isn't WALK, set the previous mode (notice usage of numbers instead
    // of eNums, when it suits us)...
    if (mouse.Mode>0) mouse.Mode=mouse.Mode-1; 
    else 
    { 
      // ...but if it is WALK mode...
      if (player.ActiveInventory!=null) 
      {
        //...and the player has a selected inventory item, set mouse mode to UseInv. 
        mouse.Mode=eModeUseinv; 
      }
      else 
      {
        // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
        mouse.Mode=eModeTalkto; 
      } 
    }
  }
}

Racoon

#33
I almost got it solved now, but I mght need a bit help for the rest.

Code: ags
if (button == eMouseLeftInv) {
// interact with item to grab it
if (mouse.Mode == eModeInteract) player.ActiveInventory = inventory[game.inv_activated];
// else process click
else inventory[game.inv_activated].RunInteraction(mouse.Mode);
}
else if (button == eMouseRightInv) 	
{mouse.Mode = eModeInteract;
mouse.UseModeGraphic(eModePointer);} 


Now I can select items in the inventory and deselect them, but only if I right click on an inventory item. So I think eMouseRightInv only gets called when the mouse is on an inventory item. What I want though is to deselect a picked item everywhere while the inventory is open.

I tried something like this, but it does nothing  :(

Code: ags
 else if (button == eMouseRight || button == eMouseWheelSouth){
    // right-click our mouse-wheel down, so cycle cursor
    if (gInventory.Visible==true){mouse.Mode = eModeInteract;
mouse.UseModeGraphic(eModePointer);} 
    else mouse.SelectNextMode();


Matti

#34
Quote from: Racoon on Sat 25/04/2020 12:43:53
Now I can select items in the inventory and deselect them, BUT only if I right click on an other inventory item. So I think eMouseRightInv only gets called when the mouse is on an inventory item. What I want though is to deselect a picked item everywhere while the inventory is open.

Ah, yes, I was confused by this too and solved it by putting this in the global script's on_event function:

Code: ags

if (event == eEventGUIMouseDown && mouse.IsButtonDown(eMouseRight) && player.ActiveInventory != null && data == gInventory.ID) 
{
  InventoryItem *ii = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (ii == null)
  { 
    player.ActiveInventory = null;   // lose active inv
    mouse.Mode = eModeInteract;
  }
}

(replace gInventory in case your GUI is called something else)

I'm not at all sure if this is the most elegant way and I think scripting inventory stuff in AGS is a bit complicated. But it works :)

Racoon

It finally works!! Thank you so much Matti! (I actually felt like shouting "Heureka" when I saw it worked)

And for the unlikely case someone finds the thread while searching for similar problmes. While looking up on_event I also found a working code for another question I had

QuoteAnd also is there an easy way to prevent the mouse cursor going to "Look" whenever items are combined?

Code: ags


function on_event(int event, int data) 
{
{
if (event == eEventLoseInventory) { //loseInventory
if ((gInventory.Visible==true) && (mouse.Mode == eModeLookat)){
Mouse.Mode=eModeInteract;}
}
}
}


Matti


Scummbuddy

#37
@Cassiebsg, I just tried the "Use a GUI as a Room-Darkening" technique. I was looking to use your method, but I found some issues with it, but it could work in a pinch on a small, easy screen.

First, I couldn't change the background color of the GUI to be "black" as AGS will use "(0 for transparent)". I did play with using just a dark gray color and changing the Transparency property to be 60 and that worked well enough.

But my background has some windows on it, and I wanted to let some "light shine through". So I instead changed from using a GUI background color, to a duplicated background image of my room, but with the window pane areas "cut out" (alpha) and the rest a 60% black covering. That looked like it would work out but then I hit another snag.  My room is a scrolling room and the GUI doesn't scroll along with the character walking. I then get a ghostly shadow of my window panes floating as I walk the character off from the starting view.

I'll probably just switch to an animated background and use SetBackgroundFrame... but then that will fail to darken any of my animated objects in the room. Hmm...
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Crimson Wizard

#38
Quote from: Scummbuddy on Fri 01/05/2020 00:54:19
But my background has some windows on it, and I wanted to let some "light shine through". So I instead changed from using a GUI background color, to a duplicated background image of my room, but with the window pane areas "cut out" (alpha) and the rest a 60% black covering. That looked like it would work out but then I hit another snag.  My room is a scrolling room and the GUI doesn't scroll along with the character walking. I then get a ghostly shadow of my window panes floating as I walk the character off from the starting view.

If there are light and dark areas in the room, and room is scrolling, you could make a big room-size object, with varying sprite translucency.
Or, you could make a room-sized GUI with varying translucency (again using a sprite).

Quote from: Scummbuddy on Fri 01/05/2020 00:54:19
I'll probably just switch to an animated background and use SetBackgroundFrame... but then that will fail to darken any of my animated objects in the room. Hmm...

In this case, you could try setting LightLevel or Tint for characters and objects, it should be easy enough to do in a loop.
Actually you may even achieve dynamic lighting change by checking where a character is (on a light spot or dark spot) in rep_exec.

SMF spam blocked by CleanTalk