1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

Windows Calling alarm on different object

Discussion in 'Programming' started by Gizimo, Jan 20, 2020.

  1. Gizimo

    Gizimo Member

    Joined:
    Jan 20, 2020
    Posts:
    2
    I am trying to create an interactive door that opens when the player presses "x" while close to it. I'm currently trying to work out how to call an alarm on the door when the player presses "x".
     
  2. tamation

    tamation Member

    Joined:
    Jul 7, 2016
    Posts:
    64
    You can reference alarms and variables from other objects by doing [object name].alarm[0], in your case probably obj_door.alarm[0] = [amount].
    Can be a good idea to preface this with "if instance_exists(obj_door)" to avoid potential crashes.
     
    Gizimo likes this.
  3. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,234
    Why not just do it in the door that seems like it would be easier?

    Otherwise you can use either the . accessor or the with statement: Addressing Variables in Other Instances.
     
  4. relic1882

    relic1882 Member

    Joined:
    Apr 5, 2018
    Posts:
    32
    I'd go with place_meeting in the step event for simplicity, depending on the complexity of your situation.

    if place_meeting with player object then check for player input. If player input is active, open the door, do whatever you need, set the alarm and proceed.

    It's an easy way to check if the player is within range, checking for input, then acting upon it all at once. Not to mention it will work for whatever door instance you create without checking specific variables.

    Edit: add more info.
     
    Last edited: Jan 21, 2020

Share This Page