Author Topic: how would i slow a for statement?  (Read 1202 times)

fixed the countdown, lemme look at the bottles of spam
new code of it:
Code: [Select]
function eat(%i)
{
commandtoserver('consume',"purifiedwater");
commandtoserver('consume',"banana");
if(%i != "stop")
{
$eatsched=schedule(10000,0,eat);
}
else
{
cancel($eatsched);
}
}

function countdown(%a, %b)
{
if(%b >= 0 && %a >= 1)
{
commandtoserver('messagesent', %b);
%b--;
schedule(%a, 0, countdown, %a, %b);
}
}

function bottlesofspam(%a, %b, %c)
{
if(%b > 0)
{
if(%c >= 3)
{
%c = 1;
%b--;
}
else
{
%c++;
}
switch(%c)
{
case 1:
commandtoserver('messagesent', %b @ " bottles of spam on the wall.");
break;
case 2:
commandtoserver('messagesent', %b @ " bottles of spam!);
break;
case 3:
commandtoserver('messagesent', "Take one down, unleash the spam...");
break;
}
if(%a > 0)
{
schedule(%a, 0, bottlesofspam, %a, %b, %c);
}
}
else
{
commandtoserver('messagesent', "Looks like we ran out of bottles of spam!");
}
}
edit: i don't think %b would work there, because i already have a check if %b is at 1 or so i think, and i wanted it so if i did bottlesofspam(0); then it would stop
edit again: updated script
edit: another problem is that i have to use exec("add-ons/client_commands/client.cs"); before i can use it, after opening BL
« Last Edit: August 31, 2010, 09:18:33 PM by phflack »

Code: [Select]
function bottlesofspam(%a, %b, %c)
{
if(%b > 0)
{
if(%c >= 3)
{
%c = 1;
%b--;
}
else
{
%c++;
}
switch(%c)
{
case 1:
commandtoserver('messagesent', %b @ " bottles of spam on the wall.");
break;
case 2:
commandtoserver('messagesent', %b @ " bottles of spam!);
break;
case 3:
commandtoserver('messagesent', "Take one down, unleash the spam...");
break;
}
if(%a > 0)
{
schedule(%a, 0, bottlesofspam, %a, %b, %c);
}
}
else
{
commandtoserver('messagesent', "Looks like we ran out of bottles of spam!");
}
}

This looks annoying, why are you making such a useless script?

Why doesn't C# have a wait(); function like Lua? It is extremely useful.


Torquescript is really similar, though. So when I look for tutorials on how to do something in TorqueScript, I look it up in C# first.

I honestly think the only reason why people say that is the file extension similarity. TorqueScript's syntax is similiar to several languages.

i'm just basing this off of the little i know about C++ :D
This looks annoying, why are you making such a useless script?
practice, i dunno

This looks annoying, why are you making such a useless script?
People have to learn this stuff somehow -- its how he chose to learn it.

one minor tweak:
Change:
Code: [Select]
function eat(%i)
{
commandtoserver('consume',"purifiedwater");
commandtoserver('consume',"banana");
if(%i != "stop")

to:
Code: [Select]
function eat(%i)
{
commandtoserver('consume',"purifiedwater");
commandtoserver('consume',"banana");
if(%i !$= "stop")

you need to use '$=' for string compare or '!$=' for string does not equal.

ahh, i haven't tested the eat function since i edited it