cmdset seems to double

26 views
Skip to first unread message

Quilnux

unread,
Feb 19, 2021, 10:24:51 PM2/19/21
to Evennia
Weird...

Ok, so I have a cmdset (attack) attached to a weapon object. When a character goes to a room with the weapon object or has the weapon object in their inventory, the cmdset from the weapon object makes itself available to the character. So far so good.

Now, if the character does into another room that either contains a weapon object, or a character that contains a weapon object, the character then ends up with two of the same cmdset.

1-attack
2-attack

The character should only have this cmdset once. Is there a way to ensure the cmdset is never given twice?

Zude Onim

unread,
Feb 19, 2021, 10:32:02 PM2/19/21
to eve...@googlegroups.com
There's probably two weapons (either held or in the room) that the
character can use.

I've encountered a similar conundrum, and what I did was make the
'attack' command on the character only.

When the character uses their 'attack' command, it then uses their
stats (strength, whatever), combined with the stats of any weapon they
have 'equipped'. 'Equip' is also a command on the character, and
weapons are "equipped = True/False". Equipped weapons can't be
dropped, etc.

Does that make sense ?
> --
> 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/c284480b-3486-47a6-8445-abbaf856a2afn%40googlegroups.com.
>

Quilnux

unread,
Feb 19, 2021, 10:35:20 PM2/19/21
to Evennia
I'm aware of what is causing it (exactly what you stated) I'm just not sure how to keep it from happening.

I would prefer to keep the cmdset tied to the weapon not the character because it will make the cmdset module so it can be used in different object typeclasses without having to manually update every typeclass I build with an attack cmdset. I wonder if there is a way to use locks to lock the cmdset to only the character with the weapon object in their inventory.

Zude Onim

unread,
Feb 19, 2021, 10:41:29 PM2/19/21
to eve...@googlegroups.com
there is a "holds" lock, but you'd still get multiple "attack"
commands if holding multiple weapons. Sorry I can't be more help.
> https://groups.google.com/d/msgid/evennia/0ffb46b4-d7e4-43e1-9fcf-78a5393624b2n%40googlegroups.com.
>

Quilnux

unread,
Feb 19, 2021, 10:55:58 PM2/19/21
to Evennia
Oh.. wait.. holds lock.. So I would put that on the weapon or the cmdset?

Zude Onim

unread,
Feb 19, 2021, 10:57:43 PM2/19/21
to eve...@googlegroups.com
Part of my Equipment Class :

class Equipment(DefaultObject):

def at_object_creation(self):
self.cmdset.add(CmdSetEquippable, permanent=True)
self.locks.add("get:true()")
self.locks.add("call: holds()")
self.aliases.add(["item","equipment"])
> https://groups.google.com/d/msgid/evennia/e1426fb0-acec-435a-bac7-25ac1cb7b21bn%40googlegroups.com.
>

Quilnux

unread,
Feb 19, 2021, 10:58:20 PM2/19/21
to Evennia
I'm gonna try that. Thanks!

Quilnux

unread,
Feb 19, 2021, 11:27:54 PM2/19/21
to Evennia
That seems to have fixed it! Thanks!

Zude Onim

unread,
Feb 20, 2021, 12:04:39 AM2/20/21
to eve...@googlegroups.com
Ok, cool ... but if you have two weapons in your inventory, you'll
probably still get two command-sets trying to activate, like before
... ???
> https://groups.google.com/d/msgid/evennia/bba2fb99-d614-4af4-b176-0a98c6e85c13n%40googlegroups.com.
>

Quilnux

unread,
Feb 20, 2021, 12:57:31 AM2/20/21
to Evennia
Yeah, I figured as much. I really don't let them have more then 1 melee or ranged weapon. They have to drop they weapon to use a different one. Ranged has a different command.

Griatch Art

unread,
Feb 21, 2021, 6:27:32 AM2/21/21
to Evennia
You could separate between weapons just being in your inventory (what holds() checks) and what weapon you are actually wielding. There is no default wields mechanism in Evennia but you could easily make one by tagging/flagging and have a wield/unwield command. Once you have a wield state, add a new `wields()` lockfunc and you are good to go.

Of course, if you allow dual-wielding you may need to handle that separately.
.
Griatch

Quilnux

unread,
Feb 21, 2021, 11:57:02 AM2/21/21
to Evennia
Yeah, I built a wielding system. I don't actually allow players to wield multiple weapons. The holds lock fixed the problem. I need to find out where in the documentation it lists all the locks and lock settings. I did a search but the search system is pretty useless sometimes. I just need to spend an hour or two just going through and looking for where everything is located in the documentation. I just haven't had the time to do that yet. I also have to spend time figuring out what is Evennia questions and what is Python questions because I'm very new to Python (this is the first time working with it). So it's been a challenge but a very fun one.

Griatch Art

unread,
Feb 24, 2021, 3:00:34 AM2/24/21
to Evennia
 The term to search for is a lockfunc, which yields the default lockfunc module where the default ones are defined: https://www.evennia.com/docs/latest/api/evennia.locks.lockfuncs.html?highlight=lockfuncs  Ignore the top of the module, it's not displayed well, but all the funcs are the lockfunc definitions available by default.
.
Griatch
Reply all
Reply to author
Forward
0 new messages