Storing Items for Later

Sometimes the player gets an item as a gift or reward. In general, we should make sure that accepting the item does not exceed cargo limits; if it does, then we need to give the player a chance to make room and return later.

The easiest way to do this is to store the reward item (or items) in a marker object and let the player take the items via a loot screen. There are two helper functions in the RPG library for this:

(rpgStoreItem sourceObj theItem)
(rpgGetStorage sourceObj) -> storageObj (or Nil)

The first function, rpgStoreItem is used to store an item on the marker. sourceObj is the object giving the reward. If the marker does not exist, rpgStoreItem creates it.

The second function returns the marker object. If the marker object does not exist, or if it is empty, then we return Nil. We can use this to decide whether or not to show a loot screen UI.

When the player receives a reward, we can do something like this:

...
(rpgStoreItem gSource giftItem)

(scrShowScreen gScreen &dsRPGLoot; {
   sourceObj: (rpgGetStorage gSource)
   })
...

The above stores the item on a marker and then brings up a loot screen to let the player take the items. If the player does not take the items (because of lack of space) then the items stay on the marker.

When the player returns, we can optionally bring up the loot screen if there are still items there:

...
(if (rpgGetStorage gSource)
   (scrShowScreen gScreen &dsRPGLoot; {
      sourceObj: (rpgGetStorage gSource)
      })
   )
Sign In
Username:
Password:
Register a new account
Forgot my password
Sign In
Cancel
Register
Username:
Password:
Confirm:
Email:
I already have an account
Terms of Service
Sign In
Cancel
Are You Sure?
Are you sure?
OK
Cancel
Error.
OK