When and when not to use objects, and how many can I have?

70 views
Skip to first unread message

USER

unread,
Nov 29, 2020, 2:28:51 AM11/29/20
to Evennia

I've been working on a MUD using this software for over a year. I don't have too many problems creating typeclasses, commands, objects, scripts, etc, but I'm uncomfortable with how, and when, to properly use objects.  I have many questions.

For instance, I am working on a system where players collect a certain resource that is, for all intents and purposes, meant to be alive, unique, and each unit has a lifespan.  I created an object that curates how many are in the world, making a new one if the total is too low.  This will, of course, fill up the dbrefs slowly, maybe 1000 per week.  How much stress does this put on the server, and in what way?  Can I have a million unique items, all objects with their own dbrefs, able to be manipulated and controlled by players?  Or should I stick with dicts when possible?  Is it a problem if many are deleted and there are hundreds or thousands of null dbrefs?  Should I implement some kind of method to filter those when searching for objects, or does django do that for me?

Most of the python I've done has been working on a MUD through evennia and a discord bot, and this is my first time using django, so this might be more of a fundamentals misunderstanding than one of evennia.

AdvTHANKSance

Quilnux

unread,
Feb 8, 2021, 7:26:28 PM2/8/21
to Evennia
Yeah, I have this question too. I have a bartender NPC that gives players a tankard of ale which is a regular object typeclass. Once the player drinks it, it basically gets destroyed. I'm curious if this is how it should be done or not.

Friar

unread,
Feb 8, 2021, 7:53:21 PM2/8/21
to eve...@googlegroups.com
Worrying about dbrefs is an old-school thinking pattern from the prior world of MUD development.  Just let it die.  A dbref is a 64bit number in the database.  
If you generated 1000 ids per day, you would literally be more likely to encounter the heat death of the universe before running out of ids.
Inactive objects are just a row in that database.  Deleted objects are just a skipped-but-indexed number.

The bigger concern will always be the amount of RAM needed to cache the active objects running around in your game.
Using python dicts however is likely to lead to an even bigger problem since they won't be automagically swapped out to the database when not in use.

--Friarzen

--
You received this message because you are subscribed to the Google Groups "Evennia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to evennia+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/evennia/fa3b5ca5-9ade-438a-8d58-15b6613d8ce2n%40googlegroups.com.

Quilnux

unread,
Feb 9, 2021, 1:34:16 AM2/9/21
to Evennia
Personally I'm not too worried about dbrefs. I do coding at work and generally know this isn't a problem but I was more interested in whether there is a better way to create temporary items (ones which have a usefulness of < 5 minutes), similar to how ndb works for attribs. But I haven't really found a way yet.

Kovitikus

unread,
Feb 9, 2021, 1:49:27 AM2/9/21
to Evennia
I think it just depends on the interactions you will have with an object.

For example, in my game I'll only have money as an attribute saved on the character or NPC as a wealth value. The only time I will create an actual gold coin object or pile of coins object is when it needs to be interacted with by a character in a physical way or when it needs to exist in the gameworld without an owner.

The same goes with my crowd mechanics. NPCs in the crowd will exist entirely as a concept, until there's a really good reason for them to be spawned in as physical objects. Such as when a character needs to physically interact directly with them; combat as an example.

In general I'm looking to fake interactions as much as possible and only create objects when it's absolutely required.

Griatch Art

unread,
Feb 9, 2021, 3:38:16 AM2/9/21
to Evennia
As others mentioned, it's more relevant to determine if you need an actual database object for performance reasons (especially if you create/destroy it a lot - maybe it's better to just hide it and reuse the same thing over and over, or to just describe the thing in text?)
You can read about the (lack of) risk of running out of dbids here: https://www.evennia.com/docs/latest/Coding-FAQ.html#will-i-run-out-of-dbrefs
.
Griatch
Reply all
Reply to author
Forward
0 new messages