{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-start-of-layout","objectClass":"System"}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Apple\"","value":"1"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"0"}},{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Pear\"","value":"0"}}]},{"eventType":"block","conditions":[{"id":"on-key-pressed","objectClass":"Keyboard","parameters":{"key":37}}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"max(Dictionary.Get(\"Orange\") - 1, 0)"}}]},{"eventType":"block","conditions":[{"id":"on-key-pressed","objectClass":"Keyboard","parameters":{"key":39}}],"actions":[{"id":"add-key","objectClass":"Dictionary","parameters":{"key":"\"Orange\"","value":"min(Dictionary.Get(\"Orange\") + 1, 5)"}}]}]}
Level 2: How to Load Dictionary Data
[condition] Dictionary: For each key
[expression] Dictionary.CurrentKey
[expression] Dictionary.CurrentValue
Level 3: Display Dictionary Data
The key here is that by add an instance variable to Slot object, it is used to know whether the item already exists.