Changing Names

I cannot get the following code to perform as expected:

(intro)
    (try [look])

(current player #player)
(#player is #in #room)
    
#room

(room *)
(singleton *)
(look *)
    You see (a #frog) here.
    
#frog

(* has form of frog)
(* has name [frog])
(prince *)
(* is #in #room)

(item *(prince $))

(name (prince $Obj))
    ($Obj has name $Name)
    (print words $Name)

(perform [kiss $Obj])
    (if)($Obj has form of frog)(then)
        (now)($Obj has form of prince)
        (now)($Obj has name [prince])
        You kiss the cute little frog, and it becomes a hideous prince.
    (else)
        (now)($Obj has form of frog)
        (now)($Obj has name [frog])
        You kiss the hideous prince, and he becomes a cute little frog.
    (endif)

I want to see, “You see a frog here,” but instead I see this:

Location
You see a here.

Could someone give me a hand?

1 Like

This is the output I get:

Dialog Interactive Debugger (dgdebug) version 0j/04.
Type @help at the game prompt for a brief introduction.


Location
You see a frog here.

> kiss frog
You kiss the cute little frog, and it becomes a hideous prince.

> l
Location
You see a prince here.

Note that I’m not using the latest version, but the one just before. I’ll check the new one when I get a chance.

Mike

Just tried it on version 0k/01. Library version 0.39 and it works as expected. Are you sure you’re using the latest version of the compiler (not just of the library)?

Wait. Ok. The first part does work as expected, but I can’t get the prince to change back.

Ok. Now I think it works as expected. Adding an “@” to make “frog” and “prince” dictionary words allows them to be used as a parameter for the “form of” trait.

I think.


(intro)
    (try [look])

(current player #player)
(#player is #in #room)
    
#room

(room *)
(singleton *)
(look *)
    You see (a #frog) here.
    
#frog

(* has form of @frog)
(* has name [frog])
(prince *)
(* is #in #room)

(item *(prince $))

(name (prince $Obj))
    ($Obj has name $Name)
    (print words $Name)

(perform [kiss $Obj])
    (if)($Obj has form of @frog)(then)
        (now)($Obj has form of @prince)
        (now)($Obj has name [prince])
        You kiss the cute little frog, and it becomes a hideous prince.
    (else) 
        (now)($Obj has form of @frog)
        (now)($Obj has name [frog])
        You kiss the hideous prince, and he becomes a cute little frog.
    (endif)

Well, I am baffled.

I have double checked, and I have the latest version of the library, the compiler, and The Å-machine, and I still get the same result (i.e., “You see a here”).

Has anyone else had issues with the latest version of the compiler (0k), prebuilt for 64-bit Linux?

I’ll investigate as soon as I can, but in the meantime could you try this in the debugger?

(trace on)
(a #frog)
1 Like

I see one bug: You have two distinct flags, ($ has form of frog) and ($ has form of prince). Setting one of them does not automatically clear the other.

You could make one of them an inverted alias for the other, if you like:

@($Obj has form of prince)   ~($Obj has form of frog)

But maybe the code would be more readable if you just reset the frog-flag when the frog is kissed:

        (now) ~($Obj has form of frog)

But something else is afoot, possibly a compiler bug. Investigating…

1 Like

Yes, this was a compiler bug. If the initial value of a per-object variable was something complex (i.e. a list), then the initial value would end up as something else. This is now fixed in 0k/02.

Thanks for reporting, and sorry for the confusion!

1 Like

I have updated, and the code—with your suggested changes—now works as desired.

You are welcome, and no worries. Bugs are par for the course. What is exceptional is that we once again have a parser-IF authoring system in regular development. Thank you for all your hard work!

1 Like