All times shown according to UTC.

Time Nick Message
00:00 evenniacode [] Owlsoup pushed to page 'Command Duration' 02[…]/Command-Duration
00:14 xrosnight_ joined #evennia
00:20 asechrest joined #evennia
00:35 AlanDill joined #evennia
00:40 VoidF0x joined #evennia
00:42 * Owljuice stares at Alan's jugular vein.
00:54 AlanDill Hey! What are you doing that for?
00:54 * AlanDill covers up his neck
00:57 Owlsoup_ joined #evennia
01:36 * AlanDill jabs Owlsoup
01:36 AlanDill wake up!
01:40 xrosnight_ joined #evennia
02:19 Zigtalk So aggressive.
02:27 xrosnight__ joined #evennia
03:24 * asechrest is totally puzzled by an error in his MUSH tutorial.
03:52 AlanDill what error?
03:57 asechrest I found the issue, but am not sure how to fix it.
03:57 It's this part of the MUSH tutorial:[…]-npc-with-editnpc
03:57 Extending the ability to a play to edit an NPC's attributes.
03:58 allie_madison joined #evennia
03:58 asechrest The code block on the tutorial page defines a tuple of allowable attributes to edit.
03:58 allowed_propnames = ("name", "power")
03:59 A bit further down, it iterates through the tuple to display the value of each allowable attribute.
03:59 propvalue = npc.attributes.get(propname, default="N/A")
04:00 * allie_madison comes in and says, "NOBODY EXCEPT THE SPANISH INQUESTITION!!!"
04:00 asechrest The problem seems to be that "name" isn't considered an attribute.  It throws an error when attempting to get the "value" of "name"
04:00 AttributeError: 'str' object has no attribute 'value'
04:00 Hi allie_madison
04:00 allie_madison Hi asechrest.
04:05 asechrest Because if I force the attributes.get function to use only the second half of the tuple ("power"), it works fine.
04:05 allie_madison .... who are you talking to asechrest?
04:06 asechrest AlanDill.  I was confused by this error and first and he inquired "what error?" just before you came in.
04:07 AlanDill Its always kind to share, even ones confusion.
04:07 asechrest I have a lot to share, then.
04:07 Confusion is my usual state.
04:07 AlanDill Attribute error 'str' has no attribute "name" because a string isnt what is expected. it is expecting a more complicated object
04:08 allie_madison type casting?
04:08 asechrest correctly pulls the value for string "power"
04:08 AlanDill there is a str() object in python, perhaps you are attempting to create a strength score, and it is confused?
04:09 asechrest This works:   propvalue = npc.attributes.get("power", default="N/A")
04:09 This doesn't:   propvalue = npc.attributes.get("name", default="N/A")
04:09 * allie_madison nods. "Yeah, it could be pulling it as a string and not a int like you want it to."
04:09 AlanDill or, conversely, your 'str' key was never assigned a value
04:10 allie_madison An int can be a string, but a string can't be a int.
04:10 asechrest AlanDill: I'm thinking you're right with that latter guess, because I don't think Evennia considers "name" an attribute.  It's classified as a key.
04:10 Or rather, THE key.  So I think the attribute.get function doesn't capture it?
04:10 AlanDill I really need to do the tutorial tonight so I can be half assed informed. :)
04:10 allie_madison hehe
04:11 asechrest, still on the NPC?
04:11 * AlanDill builds a mind reader and uses it on allie. "Handy short cut!"
04:11 asechrest Yep.  I'm on the +setNPC function part.
04:11 Spent about an hour on this last issue.
04:11 allie_madison Don't be mind reading me Alan.
04:12 you might find some crazy ideas in there.
04:12 * AlanDill scrubs his brain
04:12 AlanDill :P
04:12 allie_madison :P
04:15 AlanDill can you affirm another way that the npc does indeed have that attribute?
04:15 asechrest Well, my npc also has a combat_score attribute, and lookup is also successful for that one.
04:16 And I examine my NPC and those attributes do exist.
04:16 AlanDill ok. so that perhaps means there is a problem with the tuple list
04:17 or, that the "name" attribute lacks a value
04:17 which makes sense, because you want a value on power, but not a name.
04:18 how are you using the name?
04:19 asechrest Well, all objects have a defined name (alias: key).
04:19 AlanDill right
04:19 asechrest But I think Evennia considers that wholly separate from any defined attributes on an object, which it may or may not have.
04:20 The tutorial code suggest we can lookup/change the name just like we could an attribute, and I think therein lies the problem.
04:20 AlanDill I would think so too; there would be some things you dont want directly available in game
04:20 especially a name, since it might be important to the database
04:21 reading that part of the tutorial...
04:22 asechrest defines a getter function to get an attribute, and this section of the tut uses it.  But if Evennia doesn't consider an object's "name" to be an attribute, I think that function fails.
04:24 AlanDill paste bin your edit function?
04:24 asechrest Sure.  Want the whole thing or the code section I think the problem is in?
04:25 AlanDill probably just that section. Have you differenced it against the tutorial?
04:25 asechrest Yes, I've done a copy/paste and it still fails me.
04:25 AlanDill ah
04:25 never mind then
04:26 ...
04:26 asechrest Here's the section I mean, though:
04:26 AlanDill Hey. Name isnt capitalised in your NPC code?
04:27 asechrest Hmm, nope.
04:27 AlanDill it looks like the tutorial expects "name" but perhaps there is a case problem, or some control character somewhere.
04:28 asechrest Perhaps.  If I force "power" for the propname variable, it works, though.  Let me try uppercase Name.
04:28 Or really any other attribute.
04:29 If I change the tuple it iterates over to allowed_propnames = ("combat_score", "power)
04:29 Also works.
04:29 Just doesn't seem to like "name"
04:30 Doesn't like "Name" either.
04:30 AlanDill nod. Because it doesnt have that attribute at all...
04:32 if hasattr(npc.attributes, 'name'): print('yes')
04:32 asechrest Agreed.
04:32 AlanDill right before the troublesome line
04:33 asechrest Ok, justa sec.
04:33 AlanDill hmm. i dont know if that will look into a tuple/list though..
04:34 nah, doesnt work.
04:37 asechrest I used this:
04:37 It printed no
04:37 AlanDill i did a test and it wouldnt look into a tuple anyway, so its a bogus test. sorry i suggested it
04:38 how about
04:38 try:
04:38 print(npc.attributes.get("name"))
04:38 except:
04:38 print("no")
04:39 asechrest Well, I don't think I'd need it to?  I assign my npc, then search for an attribute "name".
04:39 Oh, another hint:
04:39 AlanDill yu dont want the default cause it would catch the exception
04:39 oh?
04:40 asechrest Within the game, this fails:  @set npc/name = Whatever
04:40 Rather, it doesn't fail, it creates an attribute called "name", rather than editing the existing name.
04:40 AlanDill ahhhh
04:40 nicely done
04:40 asechrest So that seems to confirm that Evennia doesn't consider the defined name/key as an attribute from the very start.
04:40 AlanDill good bug hunting
04:40 asechrest We teamworked it.  =P
04:41 AlanDill talking always helps.
04:41 asechrest Watch, Griatch will come in at some point and say: "duh, name isn't an attribute."  Hah!
04:41 AlanDill "What are you new? Get a clue!"
04:41 asechrest =D
04:41 AlanDill :D
04:42 asechrest For my next trick, I'll figure out how to fix the code.  Buuuuut, I dunno how to retrieve/set the name of an object in code.

← Previous day | Index | Server Index | Channel Index | Today | Atom Feed | Search | Google Search | Plain-Text | plain, newest first