Disabling functionality of Hotspots Temporarely

Started by Olleh19, Mon 23/09/2019 15:41:09

Previous topic - Next topic

Olleh19

I'm not sure that's what i want to do, but it's the best way to explain it, i think.
I have two hotspots that you should be able to go thru later in the game, but before you must have visited a specific room. So what i've done so far, is just disabled the Hotspots via two global variables, one for each. One door (is in another room) and the area (in another room aswell). However that looks strange. When i scroll over the door it should still say "door", but it doesn't when the hotspot is disabled ofc. So i thought to myself is there a way with a bool global variable where i can make it do something along the lines of "Open door *verb used* and player says "No, i won't go out there yet." and next time when specific room has been visited, *Open door verb* instead Opens the door so the player can go out.

So in other words. I'd much rather have the hotspots visible so you can see and click the Door and the Area, so that when the player clicks them it says something like "I'm not done here yet!", so the "open command" (for the door is disabled, and just look works and walk to perhaps).

I Hope you understand what i'm asking for  :) Thanks


Cassiebsg

Keep the bools and use a simple if/else condition.

Code: ags

if (canopendoor1)  // where canopendoor1 is a bool, in this case it's true
{
  player.Say("I can finally go thru the door!");
  // add code to open door and etc..
}
else player.Say("I'm not done here yet!");  
There are those who believe that life here began out there...

Olleh19

Quote from: Cassiebsg on Mon 23/09/2019 16:30:56
Keep the bools and use a simple if/else condition.

Code: ags

if (canopendoor1)  // where canopendoor1 is a bool, in this case it's true
{
  player.Say("I can finally go thru the door!");
  // add code to open door and etc..
}
else player.Say("I'm not done here yet!");  


But i'm thinking more in the terms of "previous room" couldn't you do something like if player been to room, bla bla.
But i guess the if/if else works too, i'm just a bit confused about it sometimes. :-[

Cassiebsg

#3
if (player.PreviousRoom==4) ...

or

if (HasPlayerBeenInRoom(4)) ...


They are both well explained in the manual.  (nod)
There are those who believe that life here began out there...

dayowlron

#4
  sorry, ignore me Cassie beat me
Pro is the opposite of Con                       Kids of today are so much different
This fact can clearly be seen,                  Don't you know?
If progress means to move forward         Just ask them where they are from
Then what does congress mean?             And they tell you where you can go.  --Nipsey Russell

Olleh19

#5
Thanks guys! You're the best! :)
The irony i press f1 all the time but i still managed to miss that section in the manual. (laugh)

Edit Again: To my defense. If you type "room", or "change room". You won't find it. You have to scroll thru the entire manual search for that one "hasplayerbeeninroom" section. Unless you ofc knew about it, but then why read the manual. Ff you already knew about it!
So maybe that could be fixed so it's "in the room section" for further noobs to find easier.
:)

cat

Quote from: Cassiebsg on Mon 23/09/2019 17:20:37
if (HasPlayerBeenInRoom(4)) ...

8-0  8-0  8-0

I never knew that feature existed! This will make life so much easier from now on...

eri0o

#7
adventuregamestudio.github.io/ags-manual/Globalfunctions_Room.html

This is sort of done in the new upcoming manual, maybe need to add a preword at the start of this section to say that more room related functions are available under the Room object. CW had this idea to separate the Global Functions in different categories to be able to find things easier, so by reading your suggestion I think it's aligned. So new AGS Editor on the next beta should come with the manual with these sections.

Feedback on the manual is always valuable, so whatever problem with it, it's important so it can be improved. :)

Khris

1. If both hotspots' actions depend on having entered room 4, you don't need two global bools. The game state you'll be tracking is "has the player been to room 4", and a single bool is sufficient for that.

2. You can use  HasPlayerBeenInRoom()  here but for situations where there isn't a handy function like that, you should still learn how to use bools instead. The basic idea is to pick a suitable variable name, like  playerVisitedCave  and change it in the appropriate function. In this case, that's room_Load / room_AfterFadein of the cave Room, so just go to the function (or create and link it), then add  playerVisitedCave = true;

3. Using  if  doesn't have to be confusing. It's not magic, on the contrary, it follows very strict and simple rules. Simply put, if whatever is inside the parens evaluates to true, not null or a number other than zero, the block following the condition is executed. It doesn't get much more straightforward than:
Code: ags
  if (playerVisitedCave) {
    ...
  }
  else {
    ...
  }


It's plain English.

Olleh19

Quote from: Khris on Mon 23/09/2019 18:28:08
1. If both hotspots' actions depend on having entered room 4, you don't need two global bools. The game state you'll be tracking is "has the player been to room 4", and a single bool is sufficient for that.

2. You can use  HasPlayerBeenInRoom()  here but for situations where there isn't a handy function like that, you should still learn how to use bools instead. The basic idea is to pick a suitable variable name, like  playerVisitedCave  and change it in the appropriate function. In this case, that's room_Load / room_AfterFadein of the cave Room, so just go to the function (or create and link it), then add  playerVisitedCave = true;

3. Using  if  doesn't have to be confusing. It's not magic, on the contrary, it follows very strict and simple rules. Simply put, if whatever is inside the parens evaluates to true, not null or a number other than zero, the block following the condition is executed. It doesn't get much more straightforward than:
Code: ags
  if (playerVisitedCave) {
    ...
  }
  else {
    ...
  }


It's plain English.

I'm bad at explaining myself, and i would embarase myself even more if i showed the code  (laugh). At least i've solved the hotspot disabling, it just wasn't necessary, all i needed was if, else and a bool statement, so that was correct!  :)



SMF spam blocked by CleanTalk