revUp - Updates and news for the Revolution community
Issue 130 | March 8th 2012 Contact the Editor | How to Contribute

RPG Toolkit: check your inventory
In part 4 of this series, we look at how to let your player manage inventory objects.

by Elizabeth Dalton

You can read Part One in this series here. Part Two is here. Part Three is here.

Last night I started working on a flexible object inventory system for the RPG.

In general, I'm using a substack to place one inventory object per card. I'll be using this method to store a number of components, including the image as displayed within the game, a smaller version of the image to display in the "inventory" window that I generate when the main image is uploaded, the name to use for the object, and some properties that describe what kind of object it is (e.g. EDIBLE). This will allow, for example, the user to click the "get" button, then click an object on the screen and add it to a popup inventory list.

Ok, here's what I've got so far for the Inventory system:



This is a card in a substack called "objects." The Load Image script is fairly simple:

on mouseUp
      -- get file name with dialog box
      answer file "Select the image for the object" with filter \
         "Web Graphics,*.jpg;*.gif;*.png"
      import paint from file it
      -- put icon of new image in iconid
      put the short name of last image into tempImage
      put image tempImage into image "Image"
      put the short name of image tempImage into field \
         "objectName"
      --put the icon of it into field "iconID"
      put the ID of image "Image" into field "iconID"
      -- make small version of image in Object Icon
      put image "Image" into image "imageIcon"
      -- left, top is 226, 30
      -- get max of width and height, set larger to 100, set
   -- smaller proportionally
      put max(width of image "imageIcon", height of image \
         "ImageIcon") into newScale
      set width of image "imageIcon" to width of image \
         "ImageIcon" * 100/newScale
      set height of image "imageIcon" to height of image \
         "ImageIcon" * 100/newScale
      --set the rect of image "imageIcon" to 0, 0, 100, 100
      delete image tempImage
end mouseUp
    

I seem to have a problem where after closing and opening the stack, the image attached to the "icon" goes back to full size, though. Still trying to sort that out.

Once I've got that working, the plan is to write the "get" script like this:

on mouseUp
      -- highlight gettable objects - set outer glow to true
      -- set their disable to false
      -- wait for get signal to come back
      -- hide button of taken object
      -- put && char after field "inventory"
      -- set the icon of last char of field "inventory" to icon
   -- of "gotten" button
      -- use the "inventory" version of the graphic from
   -- substack of objects
end mouseUp
  

The "gettable objects" and "gotten" button refer to button controls on the card that represent the objects in the scene that the player can use the "get" command on. Some objects will be background images only, and others will be too large to "get" (but might take other actions, like "use.")

I plan to have the "gettable" objects glow like this when the "get" button is clicked:

cake2.pngcake2glow.png

Edited because I found the parameter I want:

set the outerglow["color"] of me to "255,0,0"
  
I'll probably do something similar with the other commands I plan to use, possibly with a different key color for each command. (E.g. "use," "eat," "examine," etc.)

Speaking of verbs, I've been mulling over the "essential" list of verbs to include in a game like this for years. Some are drawn from MUD/MUSH/MOO code, others are from paper-and-pencil RPGs. Here's a short list of my favorites:

Ask
Tell
Give
Take
Examine
Fix
Make
Use
Sleep

More complicated verbs include:

Solve: [using] Language, Science, Math, History - maybe by popping up a puzzle, e.g. sudoku?
Confront (a kind of social interaction)
Perform (e.g. skit, song, dance, joke) Specify emotion to inspire
Makeover? Disguise? Decorate? disguise "target" [with "props"] as "name" "desc"
Lead (e.g. lead an NPC)
Guess? (an alternative to solve?)
Open -- open "locked item" with "tool"
Hide
program <AI object> [action....] train <animal> <trigger> <emotion> <result>
convince "target name" do "action..."
--train tiger [see object +live] [emotion hungry+2]
--train tiger [hungry>2] [eat +live]
hit "target" with "weapon" (or magical attack or telepathy)
bind "target" with "bindmat"
teach "target" "skill"
Ignore [collision objects, attacks, etc.]
Allow (allows an action to be done to PC)
Sit
Enchant: attaches attributes/commands to objects and gives them flag +MYSTIC, may be able to change other properties or see Transform/Morph
Teleport
Kiss, Hug (obviously there could be more verbs of this type, but I'm not going there)
Scan (telepathy)
Send (telepathy)
Defend
Be (e.g. be happy) (maybe "Emote"?)

I feel like I'm making good progress on this, I look forward to bringing you another installment next time!

Elizabeth Dalton

About the Author

Elizabeth started coding in 1986. She currently works as an instructional designer at a college and is researching the use of learning games and simulations. She remains on the lookout for talking animals bearing magical transformation items.

 

 

 

 

Main Menu

What's New


Get MobGUI free with a LiveCode purchase