![]() |
Making scripts shorter
Could someone tell me common things that people do that can be done in shorter ways that take up less characters (preferably a lot less...)
|
for loops! i see so many scripts that should be taking advantage of this but aren't. i'm not just talking about the scripts where people put 20 putexplosions, there's also scripts that have just a few extra lines that could be removed and more easliy understood with a simple for loop in it.
|
Quote:
|
Use with to transfer strings around instead of using server strings. More efficient and less error-prone, too
|
I've tried this a few times in Graal, but it doesn't seem to work, but it works in some other programming languages.
NPC Code: It doesn't seem to work for me. I usually have to type out the whole thing as if(var == 1 || var == 3) // stuff Has anyone else tried this before? |
Quote:
'var == (1||3)' would check wether var is true, as '(1||3)' returns true because neither 1 or 3 is false. Not sure wether it is exactly like that in GScript, but in theory it should be like that. Probably one could also save some lines by using vecx/y. NPC Code:is inferior toif (playerdir == 0) playery --; NPC Code:playerx += vecx(playerdir); |
I usually use more arrays than lots of this.vars,like:
array = {10,20,30,40}; instead of this.var1=10; this.var2=20; as Pokilty already said,i like to use for loops: for(i=0;i<4;i++){changeimgvis i,4;} instead of changeimgvis 1,4; changeimgvis 2,4; You can find many ways to make your script shorter. Btw,this remember a funny thing that ive seen,i saw a script 2 weeks ago (i wont say who was the scripter,but its a famous person),he made a scrolling message like this: NPC Code: hehe :D |
Quote:
|
Originally posted by osrs
Btw,this remember a funny thing that ive seen,i saw a script 2 weeks ago (i wont say who was the scripter,but its a famous person),he made a scrolling message like this: code:-------------------------------------------------------------------------------- if(playerenters){ message H; sleep0.5; message Hi; sleep0.5; message H; sleep0.5; message; timeout = 1; } -------------------------------------------------------------------------------- NPC Code: Just a quick script but sadly it is not that much shorter than the first one lolz Didn't test it i just figured it would work. |
Quote:
But you could do for(i=0;i<=strlen(#s(this.message));i++) instead of for(i=0;i<4;i++) |
I would have but I didn't see a blank message ; before the actual H showed up so I didnt think of it ;)
It was a blank message ; at the end thus the i<4 instead of <3 |
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
NPC Code: |
Quote:
|
| All times are GMT +2. The time now is 09:37 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.