May 22, 2012, 04:49:33 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Queston about SetControllerVariable  (Read 2379 times)
Jim
Jr. Member
**
Posts: 85



View Profile WWW
« Reply #15 on: August 30, 2008, 02:41:31 PM »

Defining Story was one of my over 100x syntax alterations.

I need a working sample please.
I haven't read the entire thread, but if you look at the space shooter sample I provided, it has examples of using these scripting functions.
http://www.ridereport.net/bv/wp-content/uploads/2008/05/spaceshooter_project.rar
Logged

www.gamecreation.ca - gamecore stuff.
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #16 on: August 30, 2008, 02:45:40 PM »

I started hunting for that very link. Thanks Jim
Logged
Jim
Jr. Member
**
Posts: 85



View Profile WWW
« Reply #17 on: August 30, 2008, 03:09:04 PM »

writer.gsl:
line 5: 'Story' is not declared
line 5: Cant' implicitly convert from 'String&' to 'int'
Quote
{void SetControllerVariable( Object@ object, const String& in name, String value)

   if (name == "Story")
   {
   Story = value;
   }
}


Is this your entire writer.gsl?? the function call SetControllerVariable is used to set something,so you need to pass it information.... that's what String value is at the end.... Is value declared?

Edit, I looked over my space shooter, and it is actually using the save game variables.... It must have been an older version using the controllervariables.


EDIT:
Can you post both entire files, reader and writer.gsl... Thanks.
Logged

www.gamecreation.ca - gamecore stuff.
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #18 on: August 30, 2008, 03:45:05 PM »

I can post this, that works now, thanks to your sample.

writer.gsl
Quote
String Story;

void Initialize( Object@ object)
{
object.SetControllerSetting("Story", "Once upon a time, there was a story that needed to be told. I just told it. The end.");
}

reader.gsl
Quote
void DynamicsAdvance( Object@ object, float seconds)
{
      print(GetGameManager().GetWorld().GetObject("writer").GetControllerSettingString("Story"));

}

Thank you. Thank you. Thank you. Everybody. I know a LOT more now.

In the end, the problem was using GetController'Variable' instead of GetController'Setting'. That's even easier than Flash now and I can code any game in 2D there. Once I get more of a grip on the 3D matrices and raycasting for real control over that 2rd axis, I'll be able to make a commercial game. All my frustration has been washed away with those 2 sweet little lines.

Now I'm gonna go and make my spider interested in more than just one of my balls.

Oh and thanks to Jim, I think I can now spawn them so I can get a bunch of spiders crawling all over my balls. I've always wanted that.
« Last Edit: August 30, 2008, 04:18:13 PM by Squat » Logged
Squat
Hero Member
*****
Posts: 592


View Profile
« Reply #19 on: August 30, 2008, 06:35:30 PM »

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
Quote
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
Quote
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.
Logged
Jim
Jr. Member
**
Posts: 85



View Profile WWW
« Reply #20 on: August 30, 2008, 08:12:35 PM »

You mean you only want to ShowTextPlain if the shout string is different? Or are you asking about doing something else?
Logged

www.gamecreation.ca - gamecore stuff.
Pages: 1 [2]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!