How do I delete a dictionary key once I've used it?

0 favourites
  • 2 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello again!

    Sorry for the second post of today, but I'm completely stumped.

    I have a dictionary that is being fed from an external file via AJAX, that works perfectly now. This file contains 15 names that are stored in 15 keys. When I run my layout it creates 12 instances of one sprite and sets an instance variable called "name" for each and that works fine. However, what I would like to do is once the sprite has been named, I would like to remove that name from the dictionary so there won't be any duplicates.

    Here is the block of events that spawns all the objects and assigns the instance variable.

    Once again, I apologize for the second post and thank you in advance,

    Jack.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • foxpawgames

    [quote:wqu7uwe6]

    you can simple delete key in your example if you use let's say variable "varRND"

    set"varRnd"= int(random(Dictionary.KeyCount)

    name=DictionaryGet(varRnd)

    delete key varRnd

    but now you have another problem...

    here is the difference between Dictionary(when the delete key) and Array(when you delete cell)

    ArrayRandomNames.capx

    DictionaryRandomName.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)