MODULE: RoomInv v3.0.0 - Updated 05 May 2008

Started by monkey0506, Sat 21/10/2006 23:11:46

Previous topic - Next topic

monkey0506

The RoomInv module emulates your character's inventory functionality for rooms themselves. You can drop off an item into a room, leave, and then come back for it later! You can even optionally use a Character to emulate an "object" in the room so the player can see the dropped items within the room itself.

Requires AGS v3.0.1 or higher!

Download
Mirror on Brinkster (load http://www27.brinkster.com/meleepta/ first)

Archived Versions
Mirror v2.0 Thanks Candle!
Mirror v1.0 Thanks Neole!

Ghost

sweet idea. this might provide a fun playground for puzzles that are off the track, i think i haven't seen any graphic adventure allowing the (mostly) free dropiing of stuff, while it was common knowledge that in interactive fiction, you could drop things to mark your path in a maze.

downloading now, will try it out.

Rui 'Trovatore' Pires

Just want to make it clear prior to downloading - it works by turning on the "key object" already in the room? Or by turning on a "dropped object" and making it into a "key object"?

Sweet and it came fast, which is good, but due to the 20 object limit still not purr-fect. Still, thumbs up!
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

Hmmm...I've been trying to decide what the best way to simulate creating a new object is. Perhaps I could let the user pass in Graphic, X, and Y parameters, then use a DynamicSprite...but it wouldn't work with functions like Object.GetAtScreenXY, so maybe a RoomInv.GetObjectAtXY function?

The way it works right now, the module just sets an Object*, and if it's non-null and is in the current room (defined by the room parameter when the inv item is added), then it's Visible property is set to true, otherwise it is set to false.

Kweepa

Quote from: monkey_05_06 on Sun 22/10/2006 21:09:39
Hmmm...I've been trying to decide what the best way to simulate creating a new object is. Perhaps I could let the user pass in Graphic, X, and Y parameters, then use a DynamicSprite...but it wouldn't work with functions like Object.GetAtScreenXY, so maybe a RoomInv.GetObjectAtXY function?

I was thinking along those lines too. You'd need to reserve a character which could be temporarily set to the position of each object to run the test.

The other problem would, I think, be baselines. You might have to render the entire screen yourself to get that to work. Some kind of engine support for dynamic objects with baselines would be good.
Still waiting for Purity of the Surf II

monkey0506

#5
Steve, that does bring up the point that walkbehinds, baselines, and all that jazz would get quite annoying...but I really don't want to have to render the whole screen. I think that the DynamicObject request could be useful. Presumably DynamicObjects wouldn't count toward a room's 20 static object limit, and would have to be removed by the user like DynamicSprites. I'll suggest it to see what others (i.e., CJ) think. ;)

Candle

#6

monkey0506

*bump for new version*

The primary advantage to this version is that it now uses Characters for displaying a room's inventory in the room instead of Objects which means that the Character can be automatically moved to the correct room instead of relying on every room to have the right Object. It also stores the order in which the items were added so you can keep track of their indices like you would a Character's inventory, and you can also fill a Character's inventory with a room's inventory so that you can display a room's inventory in a InvWindow.


Goldfish

It's beautiful in AGS to see how the simplicity and robustness allows such great ideas to be implemented QUICKLY rather than needing to rewrite source all the time. Really showcases game scripting versatility and power imo.

riseryn

Hi monkey
your module seems to be exactly what im needing.

Is it possible to have an exemple on how to use it?

Id like to know how exactly to set an item in a room, pick it to add it to the player inventory and drop it in the same room or another one.
I read the script but im not sure how to use it.

monkey0506

#11
Assuming you're using v2.0 it should look something like this:

Code: ags
RoomInv_Rooms[player.Room].AddInventory(iKey); // drop the key in the current room


Honestly this module's a bit messily programmed, I'd like to write a new version of it which would actually be pretty simple. If you need further help I'll see what I can do, but I can probably release a new improved version of the module in the next few days. BTW, are you using the latest beta releases of AGS? Otherwise, which version are you using?

EDIT: Just wanted to give an update to riseryn, I have the new version at about 99-100% scripted, but I haven't fully tested it yet. I need to do more tests with larger amounts of inventory items, adding the same item multiple times, and inventory in multiple rooms (and combinations of the three) before I feel confident in releasing this. I've completely revamped the system and it will require AGS 3.0.1 or higher, but you said you are using 3.0.1, so this shouldn't be a problem. I finally got started in that new job (after having been hired 2 weeks ago I finally started my on-the-floor training), so I can't make any final promises, but I would definitely say you would be safe expecting an update sometime this upcoming week. ;)

riseryn

#12
Thanks Monkey
Im using last AGS 3.01. and module 2.0
If you are releasing a new version i just wait for it.
I need this module for my game .
It s an important part of the gameplay.

monkey0506

The new version of the module is now official! This complete rewrite of the module from scratch allows more and improved functionality for your room's inventories. Inventory character positions are now remembered when re-entering the room, you can add/lose inventory items multiple times, and the module has been restructured to provide the easiest usage yet!

Hooray propaganda! ;D

Rui 'Trovatore' Pires

#14
A couple of questions spring to mind - what are the inventory objects in the rooms, are they objects or characters? At what coordinates are they set? Does this mean each room requires a character to serve as inventory?

I bring these up because these are the sort of things I'd expect to find about in a ReadMe file, but the TXT file enclosed doesn't answer these questions...

EDIT - And am I right in thinking that the objects aren't meant to be visible unless optionally? That's not exactly the first thing that springs to mind, one immediatly thinks of Kyrandia-style object-dropping, so it's also worth a mention.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

#15
I thought it would have been explained by the function/property list:

What are the inventory objects in the rooms, are they objects or characters?

InventoryItems can be represented visually within the room via the use of Characters, however it isn't necessary to have a Character assigned.

At what co-ordinates are they set?

If the item has a Character set it can be repositioned anywhere in the room using the Character's x/y co-ordinates.

Does this mean each room requires a character to serve as inventory?

No, the usage of Characters is completely optional as a visual representation of the items in the room. You can have a different Character for each item, no Characters at all, or any combination between.

There is a basic structure represented by the RoomInv array, one unit for each room, indexed by the room's ID. Each unit contains an array to hold the information about that room's inventory. The inventory items are stored in the Items property. To find out the fifth item in room 12's inventory you would use:

Code: ags
RoomInv[12].Items[5]


This array is read-only. To set the items you use the AddInventory function which accepts an optional index parameter:

Code: ags
RoomInv[12].AddInventory(iKey); // add the key item to room 12
RoomInv[12].AddInventory(iToothbrush, 0); // hygiene first!


The Items array is indexed from zero, so to insert the toothbrush item as the first inventory item in the room, we simply passed 0 as the index for our item.

The rest is pretty similar to the way the Character inventory functions work.

To allow the user to actually see the item, we have the option of using a Character within the room, or filling a Character's inventory with this room's inventory and displaying it in an InvWindow. First we'll see how to display the character in the room:

We set the character we want to use via the SetCharacterToUse function like this:

Code: ags
RoomInv[12].SetCharacterToUse(iToothbrush, cToothbrush);


The first parameter is the InventoryItem we want to link the Character to. Here we're setting up the toothbrush to be shown in the room. The second parameter is the Character that we will use to show the item within the room. So we could have a Character named cToothbrush that would be an object that we could use within the room as a visual representation of our toothbrush. Using a Character allows us to port this object between rooms. SetCharacterToUse can also specify co-ordinates for the character at the same time the character is set.

There are also extender methods implemented directly as Character functions to quickly allow you to drop/pick up either a single InventoryItem, or alternately the entire Character/Room inventory at once. The included documentation should cover this. We will use these to implement the second method of displaying our inventory.

Code: ags
cToothbrush.ClearInventory(); // completely wipe out this character's inventory
                              // he's just a portable object, so we can use his to display the room inventory
cToothbrush.PickUpInventory(false); // the parameter here allows us to optionally remove the inventory items from the current room completely
                                    // we don't need to remove them completely, so we'll leave them there
invCustomInventory.CharacterToUse = cToothbrush; // finally, display the room's inventory (via the toothbrush object character) in our InvWindow


Hopefully this should be enough to answer your questions about the module. Oh also:

I thought I downloaded v3.0.0 of the module, but when I import it AGS there's no version information at all!

I forgot to include version information in the module (oops). I will fix this as soon as possible.

riseryn


Rui 'Trovatore' Pires

QuoteI thought it would have been explained by the function/property list:

Ayuh, but that's not really user-friendly. :) You have to cover your bases and make sure it's easily understandable, and just listing what each function does gives no idea of the global, big picture. You see, the answer to my questions are important info for a ReadMe, and all the other cool information you just gave me would be perfect for example code, commented and everything.

Basically, if you don't include a demo game, or example code, you should be careful to give as much descriptive information as you can...

;)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

monkey0506

I guess in some ways I've always taken it somewhat for granted that users of my modules would read over the function list to see what everything is meant to do and would thereby gain an understanding of how the module is to be used. Of course I have been asked several times to explain myself so one may think I'd have gotten the hint by now! 8)

Quote from: Rui 'Trovatore' Pires on Tue 06/05/2008 08:53:17And am I right in thinking that the objects aren't meant to be visible unless optionally? That's not exactly the first thing that springs to mind, one immediatly thinks of Kyrandia-style object-dropping, so it's also worth a mention.

The problem here is that I was trying to avoid forcing users to supply a Character for each item in the room's inventory. I wanted to provide means for this to be done because as you say most people will tend to think of a system such as Kyrandia, but I wanted to do so without constricting usability.

The idea in the current method is you can assign a character to an inventory at any time using the SetCharacterToUse method. So presumably if you did have a group of characters you wanted to assign and then use throughout the game you could do something along the lines of this in game_start:

Code: ags
int i = 0;
while (i < eRoomInv_MaxRooms) {
  RoomInv[i].SetCharacterToUse(iToothbrush, cToothbrush);
  RoomInv[i].SetCharacterToUse(iKey, cKey);
  RoomInv[i].SetCharacterToUse(iBook, cBook);
  // etc.
  i++;
}


Then you could easily avoid having to manually set it. Your items would already be set up for all the rooms and then the module would handle the rest of the work itself (I think...I haven't actually done any extensive testing of this). Perhaps I should include some of these examples in the documentation eh? :)

Knox

Sorry to re-open, but would there be an active link somewhere to this module? It seems they are all dead and not to be found on american girl scouts :P
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk