This is an old revision of the document!
Communication
The back and forth method (by Cherryistired)
I figured out code on how to get two ghosts to have an actual conversation back and forth!
For debugging purposes at least, I have a menu option to Start conversation with the target ghost.
// Optional: This is part of a menu to start the conversation “\n\n[half]\![*]\q[Start Ghost Convo,InitiateGhostConvo]”
Then this function starts the conversation. Replace SPEAKERGHOST with the name of the ghost currently speaking. Replace TARGETGHOSTNAME with your intended conversation target. The important part is the \![raiseother,…] command.
Select.InitiateGhostConvo
{
"\0\s[0]* yo TARGETGHOSTNAME that you?\![raiseother,TARGETGHOSTNAME,OnCommunicate,SPEAKERGHOST,greeting]\w8\w8\e"
}
Now, add this in commu.dic for each ghost:
The OnCommunicate function needs this bolded text added somewhere:
OnCommunicate
{
if reference0 == “SPECIFIC/TARGET GHOST NAME"
{
TalkToSpecificGhost
}
--
if reference0 == "user" || reference0 == "User"
{
//---- 사용자로부터의 이야기에 대답
ReplyToUser
}
else
{
//---- 유령로부터의 이야기에 대답
ReplyToGhost
}
}
(tbh that's probably not the best spot to drop it in OnCommunicate, but it works there)
Put this anywhere in Commu.dic:
// This function handles incoming and outgoing dialogue for the specified ghost.
TalkToSpecificGhost
{
case reference1 // reference1 is the name of the conversation piece
{
when "greeting"
{
"\0\s[0]* hey there TARGETGHOST. this is greeting leading to part1. \0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST,part1]\e"
}
when "part1"
{
"\0\s[0]* that's cool man. this is part1 leading to part2\0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST,part2]\e"
}
when "part2"
{
"\0\s[0]* i ran out of things to say, but this is part2 leading to part3\0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST,part3]\e"
}
when "part3"
{
"\0\s[0]* i ran out of things to say, but this is part3 leading to part4 \0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST,part4]\e"
}
when "part4"
{
"\0\s[0]* i ran out of things to say, but this is part4 leading to ending\0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST,ending]\e"
}
when "ending"
{
"\0\s[0]* this is the end of our conversation. bye bye!"
//\0\![raiseother,TARGETGHOST,OnCommunicate,SPEAKERGHOST]\e"
}
}
}
Remember, the above text needs to be added for BOTH ghosts, and replace the SPEAKER/TARGETGHOST name with the correct name. The names will be swapped in the 2nd character's commu.dic file so don't forget.
This is surely not the best way to implement it, but it’s what I got to work so far, and is mainly just to share with zarla-s because it's too much for regular msgs haha.
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.