Move an object multiple times

[QUOTE=hosler;107929]All sleep does is pause for some amount of cpu cycles.[/QUOTE]
Yes, the game stops rendering, streaming sound, and transmitting network data entirely because of a sleep command in a script. You’ve got it. Let me say this again: you don’t know.

[QUOTE=Codr;107931]Yes, the game stops rendering, streaming sound, and transmitting network data entirely because of a sleep command in a script. You’ve got it. Let me say this again: you don’t know.[/QUOTE]

Ill say it again too: I really dont know.
Anyway, im pretty sure sleep only pauses the script it’s in. Not the whole game.

GS1 is read like a book, and when a sleep occurs, it pauses reading for X amount of seconds, then continues reading. Php’s sleep function has about the same behaviour.

Right. But if you play a sound and then execute a sleep it wont just stop the sound/music prematurely.

[QUOTE=hosler;107934]Right. But if you play a sound and then execute a sleep it wont just stop the sound/music prematurely.[/QUOTE]

No, it won’t. It just won’t execute what comes next until the timer has ended. Anything executed before won’t be paused.

Just trying to fix this misinformation
[QUOTE=Codr;107931]Yes, the game stops rendering, streaming sound, and transmitting network data entirely because of a sleep command in a script. [/QUOTE]

There are plenty of other things you can do to make time pass without stopping the whole script.

[QUOTE=hosler;107936]Just trying to fix this misinformation[/QUOTE]

He was sarcastic…

In both the NPC-server and the GameEngine I’m working on, the scripts run asynchronous and have no sleep function, btw.

[QUOTE=Cadavre;107938]He was sarcastic…[/QUOTE]

Nope. Codr has no sense of sarcasm.

[QUOTE=hosler;107929]All sleep does is pause for some amount of cpu cycles.[/QUOTE]
[QUOTE=Codr;107931]Yes, the game stops rendering, streaming sound, and transmitting network data entirely because of a sleep command in a script. You’ve got it. Let me say this again: you don’t know.[/QUOTE]

He was obviously making fun of your statement about the cpu cycles. lol

[QUOTE=Spooon;107930]
I think you want something like this.

if (created) {
  this.mode = 4;
  timeout = 0.05;
}

if (playerchats) {
  tokenize #c;
  if (strequals(#t(0),/move)) this.mode = strtofloat(#t(1));
  else if (strequals(#t(0),/stop)) this.mode = 4;
  timeout = 0.05;
}

if (timeout) {
  x += vecx(this.mode);
  y += vecy(this.mode);
  timeout = 0.05;
}

“/move 0” makes it move up. “/stop” makes it stop. Pretty basic.
[/QUOTE]

ew

[QUOTE=Cadavre;107943]He was obviously making fun of your statement about the cpu cycles. lol[/QUOTE]

That’s how a cpu keeps time. Time on a computer is a function of cpu ticks and cpu speed. So when you tell a script to sleep a number of seconds you are actually telling the script to stop running for a some amount of cpu cycles. I never said that the entire game stops during a sleep command.

[QUOTE=tricxta;107944]ew[/QUOTE]

As if, faggot.

[QUOTE=Spooon;107953]As if, faggot.[/QUOTE]

Lol @ neg rep

You have your script looping unnecessarily where instead of feeding it a broken value you could just break the loop.

if (timeout) {
  x += vecx(this.mode);
  y += vecy(this.mode);
  timeout = 0.05;
}

becomes

if (timeout && this.mode < 4){
  x += vecx(this.mode);
  y += vecy(this.mode);
  timeout = 0.05;
}

Sure, it’s not much, but stack of a few shit scripts on top of each other and you’ll eventually notice some lag.

Just because it’s graal, and just because it’s a noob language doesn’t mean you can throw away efficiency.

That’s all? I thought you were talking about the tokenize or something. I just wrote it up and didn’t test it lol

Yeah, that’s better for lag.