About Store Forum Documentation Contact
Donations:
197$/mo



Post Reply 
Constant Object
Author Message
AndrewBGS Offline
Member

Post: #1
Constant Object
I'd like to find out some details about what the constant checkbox means for an item. I'm currently having many problems loading and saving, and I think one of them has something to do with this.

Does it mean the object can't be edited? Or it can, but the changes won't be saved/loaded?
Does const refer to the object's custom list of parameters I'm building, or to the "hidden" object parameters, like it's size and such? Or both? I would really appreciate some details on what this means and what's the indicated way of making use of it. We could use a better documentation for the engine.
05-21-2013 12:28 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Constant Object
Hello,

All the comments are in the gui element description just move the mouse over it and it should display help.
In short: you can access/modify the game object in game, but save/load won't be called (changes won't be saved), instead it will always be recreated as brand new/fresh object as from the start when loading game or travelling to the area in the future.
05-23-2013 02:20 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #3
RE: Constant Object
Thanks. I read the comments but I wasn't sure I understood it right.
So if I have an object, let's say again the apple, and want to change only one of the parameters of the apple, but the rest be a constant, can't I somehow do this?

Is just the Item super.save() function that won't be called? Can I have my custom save and load code working but still have the item checked as a constant?
05-23-2013 07:43 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #4
RE: Constant Object
Ok here's a question:
I have some items (Apples of course) that should be constant. However, for my inventory functionality, items have an extra parameter STACK, which is NOT constant. I want to make my apples constant to save space, but I want my stack number to be saved/loaded also. How should I do this?

Should I manually call item.save for all items in inventory, and in the item.save save ONLY the stack number of my apples?
06-08-2013 08:31 PM
Find all posts by this user Quote this message in a reply
Rubeus Offline
Member

Post: #5
RE: Constant Object
Andrew, because your apples are an object which the player can pick up and put in his inventory, they should not be constant.
A (lame) example of constant is an NPC chicken pecking the ground around a barn. The player can interact with it, chase it, possibly even kill it. But the player cannot pick it up and put it in his inventory, it has no events associated with it, etc. So when the player leaves and comes back, the chicken respawns in the same spot, alive, pecking the ground like before. We do this because saying the chicken is dead when you return isn't necessary. (Also, think about kicking physics objects around the town, things like that.)
Calling your apples constant(speculation here) probably sets the CanBeSaved variable to false, so save/load won't be called anyways. But seeing as you transferred the apples to your inventory, calling them constant may cause unexpected issues when save/load are called.
Keep in mind that if you are saving a few variables, the size will be fine. I'd recommend just doing a save/load for anything you are unsure about. You can go back later and optimize to const some of the unnecessary stuff.
06-08-2013 09:26 PM
Find all posts by this user Quote this message in a reply
AndrewBGS Offline
Member

Post: #6
RE: Constant Object
Thanks a lot for the compelling explanation smile

I'll stick to your advice now, leave my apples non-constants and worry about optimization later.
06-08-2013 10:44 PM
Find all posts by this user Quote this message in a reply
Post Reply