Just for fun, and to test that I can read AND write this way, I came up with a stupid example:
Make 2 objects named reader and writer and assign each scripts.
reader.gsl
void DynamicsAdvance( Object@ object, float seconds)
{
String shouted = GetGameManager().GetWorld().GetObject("writer").GetControllerSettingString("shouted");
if (shouted == "notdone")
{
Object@ writer = GetGameManager().GetWorld().GetObject("writer");
String shout = writer.GetControllerSettingString("Story");
GetGameManager().ShowTextPlain(shout, 1);
writer.SetControllerSetting("shouted", "done");
}
}
writer.gsl
String Story;
String shouted;
void Initialize( Object@ object)
{
object.SetControllerSetting("Story", "I'm telling a great story!");
object.SetControllerSetting("shouted", "notdone");
}
bool HandleEvent( Object@ object, const String& in event, GameEventParams@ params)
{
if(event == "EnterProximity")
{
print("ENTERED");
object.SetControllerSetting("Story", "YOU CHANGED THE STORY!!");
object.SetControllerSetting("shouted", "notdone");
return true;
}
else
{
object.SetControllerSetting("shouted", "done");
}
if(event == "ExitProximity")
{
object.SetControllerSetting("shouted", "notdone");
print("EXITED");
object.SetControllerSetting("Story", "BACK TO THE ORIGINAL STORY!!");
return true;
}
return false;
}
So the story starts out as a great story and is printed to the screen as soon as the world loads up. I set it to short so I could check that it wasn't constantly triggering. When you enter the input radius of the writer object, it changes the story variable and also a call to allow for the text to be printed through the reader script. The reader script constantly monitors the writer object's variable and checks first if it's allowed to print the text. If it is then it does that and then sets the writer's call to disallow printing. It's always got the updated "Story" and "shouted" variables.
Is there a way to get the variable only once and then only send it again when it's altered? I'm guessing I'm heading back to the top of this thread for some more examining on that?
I realized during this part that HandleEvent acts almost exactly the same as DynamicAdvanced while there's actually something in the input area. With that, if I didn't have the option of the writer script getting a variable change from the reader, then the exitproximity would set the allow to yes and then nothing would turn it back off and the reader would constantly be recieve the permanent yes command stuck in the writer.