Page 1 of 1

How to check if location is public or if player is alone

Posted: Wed Nov 17, 2021 8:49 am
by Rizean
There is currently a bug with clearGetList(), once that is fixed it will make the is alone check more useful.

Action Code for interaction to test the getTarget code

Code: Select all

ACTION_UNIQUEID: rizean_testing_locationTest
ACTION_NAME: Rizean Location Test
WHERE: pc, interaction
WHEN: 0 - 24
MINUTES: 1 - 1
TIMEOUT_MINUTES: 0
ALSO_TIMEOUT: 
EFFECTS: 
CONDITIONS: 
MOVE_FIRST: false
SCENE_ALWAYS: rizean_testing_locationTest
ANIMATION: browse
WHO: Target = getTarget();

Scene Code

Code: Select all

WHAT: 
WHERE: 
WHEN: 0 - 24
WHO: none
OTHER:

sceneStart()
  Target = getTarget()
  isTargetValid = Target.isValid()
  isPublic = WHERE !== Home && WHERE !== residential
  If isPublic
    "We are in a public location"
  Else
    "We are in a private  location"
  EndIf
  isSemiPublic = WHERE === nightclub || WHERE === pub || WHERE === theatre || WHERE === toilets || WHERE === bar || WHERE === biergarten || WHERE === cinema || WHERE === brothel
  If isSemiPublic
    "We are in a semi-public location"
  Else
    "We are not in semi-public location"
  EndIf
  isSexLocation = WHERE === Home || WHERE === residential || WHERE === brothel || WHERE === nightclub
  If isSexLocation
    "We are in a sex location"
  Else
    "We are not in sex location"
  EndIf
  // Are we alone?
  temp = getPersonHere()
  count = 0
  While temp.isValid()
    count += 1
    "Found <temp.name> count: <count>"
    temp = getPersonHere()
  EndWhile
  If isTargetValid
    "There are <count> Actors here not including the <Target.name>."
  Else
    "There are <count> Actors here."
  EndIf
  If count > 0
    If isTargetValid
      "We are not alone, there are <count> Actors here not including <Target.name>."
    Else
      "We are not alone, there are <count> Actors here."
    EndIf
  Else
    If isTargetValid
      "We are not alone with <Target.name>."
    Else
      "We are alone."
    EndIf
  EndIf
  "Resetting the get list."
  // This should reset the get list, and we should again be able to use getPersonHere(), but is currently broken.
  clearGetList()
  "Calling getPersonHere"
  temp = getPersonHere()
  If count > 0
    "Found '<temp.name>' -- this should not be empty"
  EndIf
sceneEnd()