Skip to main content

Is it possible to add value to some buttons?

Comments

2 comments

  • Matthijs Broekhuizen

    Here's an example using code in a code block that should do what you want. This assumes you have spots called 'key1', 'key2' and 'key3' for each of the keys. The keys have to be clicked to be found.

    var key1Found = false;

    var key2Found = false;

    var key3Found = false;

    var key1 = Space.getSpot('key1');

    var key2 = Space.getSpot('key2');

    var key3 = Space.getSpot('key2');

    var chest = Space.getSpot('chest');

    function onClick(events)

        {    

              if (events.spot.name == key1.name )

              {

              key1Found = true;              

              }

              if (events.spot.name == key2.name )

              {

              key2Found = true;              

              }

              if (events.spot.name == key3.name )

              {

              key3Found = true;              

              }  

              if (events.spot.name == chest.name)

              {

                if (key1Found && key2Found && key3Found)

                {

                    // Write code here to execute if the chest is clicked while all keys are found.

                }

                else

                {

                    // // Write code here to execute if the chest is clicked while not all keys are found.

                }

                               

              }  

        }


     
    0
  • Daniel

    Hi Matthijs,

    Thanks for your reply and for sharing your code example! It's really helpful and well-structured. 

    Daniel

    0

Please sign in to leave a comment.