This is an old revision of the document!
Communication (Levidre)
Communication | |
---|---|
Type | Guide |
Category | AYA/YAYA |
Author(s) | Levidre |
Published | Unknown |
The communicate method (by Levidre)
The advantage of the back and forth method is that the ghost can call any function that starts by On and not only OnCommunicate. It calls the function specified in the raiseother command. Though it's always better to know which ghost called you and it would allow the other ghosts to use both methods if it calls OnCommunicate.
The “communicate method” uses the communication between two ghosts when the back and forth method was forcing the other ghost to run a function. The inconvenient of it is unlike the back and forth method it would always call OnCommunicate.
How to implement the communicate method
Starting a communication with an other ghost is simple. You just need to put res_reference0=“GHOSTNAME” before the line of dialogue, where you replace GHOSTNAME by the name of the ghost with who you want to communicate. The line of dialogue would be sent to the other ghost. The other ghost OnCommunicate would run with in reference0 the name of the ghost who communicated and reference1 the dialogue said.
The advantages of this method, in plus that a shorter command, are being able to have more information. The information given by the back and forth method are only the references sent through the command when the communicate method already gives all the information in the references by default : the name of the ghost who communicated in reference0 and the dialogue sent in reference1. So with the communicate method, putting all the information in the references or creating new functions isn't needed.
A little example (keep in mind that ReplyToGhost is called in OnCommunicate, so the references' value don't change) :
ReplyToGhost { res_reference0 = reference0 dialogue_sayed = TOLOWER(reference1) if reference0=="a_ghost" { "\0\s[0]* Hello a_ghost. How are you today ?\e" } elseif "hello" _in_ dialogue_sayed { "\0\s[0]* Hello, how are you ?\e" } elseif "how are you" _in_ dialogue_sayed { "\0\s[0]* I'm fine, and you ?"\e } else { "\0\s[0]* Hello %(reference0), I didn't recognized you nor understood what you said.\e" } }
With this method, modifying the two ghosts isn't needed. You can just check for particular dialogues and put responses to them. You can do both general and precise stuffs.