Author Topic: My scripting problems: 0  (Read 4278 times)

I am getting better at torque script, though still some problems. Here they are(list will be updated regularly):


1. I was quickly making a script for toggling a special mode, when i found it came up with a syntax error. I have commented where it is, though i have no idea how there could be an error there (the '}' symbol). Here it is: Fixed. Thanks to Pew446.

Thanks in advance to anybody who helps.
« Last Edit: June 12, 2010, 10:14:52 AM by Sammygood »

a lot of the addons have commandToServer and commandToClient functions in them.  you can open the zip file and look.

What are you trying to do?
What have you tried to do?
and what happens? (other than 'it doesnt work')

I have looked at them. The only way i can get it to work is when i copy/paste and change the script. When i try... OH sorry, it was a simple mistake :). Anyway, thanks for posting! Sorry for wasting your time :(
« Last Edit: June 07, 2010, 10:35:29 AM by Sammygood »

3.
client.cs
Code: [Select]
function clientCmdPing()
{
   commandToServer('Pong');
}
server.cs
Code: [Select]
function serverCmdPong(%client)
{
   %client.pong = 1;
}

commandToClient(findClientByName("bob"), 'ping');

4. getSimTime() returns the time in milliseconds since Blockland loaded. It's a stable way to check the exact time at which an event occured.

It's a stable way
I'm guessing you mean that it's not thrown off like schedule() through lag?

I'm guessing you mean that it's not thrown off like schedule() through lag?
I'm not sure what I meant now but let's go with that

Thanks Amade  :cookieMonster:. One more question, how would you use getsimtime() in a script? I still don't understand how you would use it. For example(i don't think this would work):
Code: [Select]
getsimtime()
simtime + %var

OR
Code: [Select]
getsimtime() + %var
Code: [Select]
echo(%simtime); ???

Please just give a small example.

« Last Edit: June 02, 2010, 02:44:21 AM by Sammygood »



You forgot to close the messageAll().
As in forgot this: )
Alsways check your script for any missing characters when finding a syntax error.

Also, i don't know if it is something critical, but i believe a set-up like this would be better:
Code: [Select]
%toggletest = 0;
function servercmdtest(%client)
{
   if (%toggletest=0)
   {
      messageAll("ToggleTest has been turned /c2ON.");
      %toggletest = 1;
   }
   else if (%toggletest=1)
   {
   messageAll("ToggleTest has been turned /c2OFF.");
   %toggletest = 0;
   }
}

Thanks! It seems i keep on missing little things... :cookieMonster:

Now its working.

Thanks! It seems i keep on missing little things... :cookieMonster:
I know all about it. ;)


Wait, why on earth doesnt it do anything!!!???
I type /test then it doesnt do anything.
When i type exec("config/Test.cs"), it says that it is working(no syntax error) then when i type /test it does nothing!

Haha, i just noticed the wrong use of =.
Put in two of them when you try to compare things.

For more information i would like to refer you to the toque functions guide that is also in the sticky (Article A.1.4.).
So it would be:
Code: [Select]
%toggletest = 0;
function servercmdtest(%client)
{
   if (%toggletest == 0)
   {
      messageAll("ToggleTest has been turned /c2ON.");
      %toggletest = 1;
   }
   else if (%toggletest == 1)
   {
   messageAll("ToggleTest has been turned /c2OFF.");
   %toggletest = 0;
   }
}