About Store Forum Documentation Contact



Post Reply 
[solved] player item container behaving differently after loading a save
Author Message
para Offline
Member

Post: #1
[solved] player item container behaving differently after loading a save
Hi,
I can pick items from the world to players inventory, I can also drop those items back into the world and am able to pick them up and drop them down multiple times. The problem occurs when I save and later load the game, the players inventory items are loaded successfully (or so it appears), I can drop them back into the world, the physics still work, but I'm unable to pick these items back up?


Hopefully relevant info:

in my player class derived from Game::Chr, I have:
Code:
Memx<Game::Item> inventory;
virtual Memx<Game::Obj>* itemContainer() {Memx<Game::Obj> &ic=inventory; return &ic;}
I overloaded the base method itemContainer() to auto-include inventory in the save game, as commented in the headers

also:
PHP Code:
//global containers
Game::ObjMemx<Game::Item  Items;

// world types setup
void InitGame()
{
        ...
        
Game::World.setObjType(Items  OBJ_ITEM  );
        ...

..and in UpdateGame() i use itemPickUp() and itemDropDown() base methods.

I also tried manually saving the inventory and not overriding itemContainer() method, either way the results are the same, the items get saved and loaded, they can be dropped via itemDropDown(), but I can't retrieve them from the world afterwards.. any ideas what i'm missing?
(This post was last modified: 04-07-2013 03:59 PM by para.)
03-24-2013 09:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
para Offline
Member

Post: #2
RE: player item container behaving differently after loading a save
Maybe I over-complicated my explanation... more simply put:

Me picks up item, me drops down item, picks up, drops down, many times, all is ok. Save, load, looks ok, smells ok, me drops item, me can't pick item up again. Me angry! me smash keyboard!

Esenthel?
04-03-2013 11:09 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #3
RE: player item container behaving differently after loading a save
I like that explanation a lot more!! Gave me a good laugh. I really wish i could help you now.
04-03-2013 11:13 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: player item container behaving differently after loading a save
lol yeah I agree, much better smile

Did you check the tutorial "Game Basics / 21-Inventory" in 2.0?

Just tried it with your scenario, drop/pick up after save/load and it works.
04-04-2013 01:14 PM
Find all posts by this user Quote this message in a reply
para Offline
Member

Post: #5
RE: player item container behaving differently after loading a save
Yes, I always check tutorials and forums before I post.. My code was ok, but I identified what is causing the problem:

Code:
Game::ObjMemx<Game::Static> Statics;
Game::ObjMemx<Game::Animatable> Animatables;
Game::ObjMemx<Game::Item> Items;
Game::ObjMemx<Player> Players;
Game::ObjMemx<Game::Destructible> Destructibles;
Game::ObjMemx<Game::ObjParticles> WorldParticles;
Game::ObjMemx<Game::Item> Props;  // <----------- problem
Game::ObjMemx<Game::Chr> Chars;


Code:
    // create the world
    Game::World.activeRange(D.viewRange())
        .setObjType(Statics, OBJ_STATIC)
        .setObjType(Players, OBJ_PLAYER)
        .setObjType(Items  , OBJ_ITEM  )
        .setObjType(Destructibles, OBJ_DESTRUCTIBLE )
        .setObjType(WorldParticles, OBJ_PARTICLES )
        .setObjType(Props, OBJ_PROP ) // <------ problem
        .setObjType(Animatables, OBJ_ANIMATABLE )
        .setObjType(Chars, OBJ_CHR )
        .New("world/temp3.world");

Seems like you can't use the same class for two containers, or the item get's dropped in the wrong one? I'm curious why is this, as everything seems to work as expected so far, only itemContainer after loading a save is affected.
04-04-2013 03:55 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: player item container behaving differently after loading a save
Hi,

Yes that could be the problem, please use one container per/class/type.
04-07-2013 11:45 AM
Find all posts by this user Quote this message in a reply
Post Reply