Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A simple script for you !! (WARNING: has errors) (https://forums.graalonline.com/forums/showthread.php?t=62611)

steve2 12-02-2005 01:38 PM

A simple script for you !! (WARNING: has errors)
 
Hello Guys!

Hmm this isnt that hard script its very simple but i still like this light effect....
I will give u this for free use and to learn of it, i think it can be helpfull if u new to gscript....just copy this script into a npc in ur leveleditor and touch it and u will have this weapon and can try it :) (use addweapon for online use and if u got NC in RC u could add it there :rolleyes: )
Feel free to edit it ;)

Keep trying and scripting and if u got any Questions about any scripts or such just feel free to post them here :D

Greetings

Steve -NAT-

PHP Code:

//#CLIENTSIDE
//NPC made by steve
// Light effect

if(created){
  
setimg block.png;
  
color = {0,0,0,0};
  
timeout 0.05;
}
if (
playertouchsme){
  
toweapons Light Mouse;
}
if(
timeout){
  for(
010++){
    
this.= (this.10) ? (this.0.5) : this.0;
    
showimg this.i,light2s.png,mousex,mousey;
    
changeimgcolors this.i,color[0],color[1],color[2],color[3];
    
changeimgzoom this.i,random(0.1,0.9);
    
changeimgvis this.i,1;
  }
  
timeout 0.05;
}
if(
playerchats){
  if(
strequals(#c,/red)) color = {0.5,0,0,0.5};
  
elseif(strequals(#c,/green)) color = {0,0.5,0,0.5};
  
elseif(strequals(#c,/yellow)) color = {0.5,0.5,0,0.5};
  
elseif(strequals(#c,/blue)) color = {0,0,0.5,0.5};
  
elseif(strequals(#c,/white)) color = {0.5,0.5,0.5,0.5};
  
elseif(strequals(#c,/end)) color = {0,0,0,0};
}
if (
weaponfired) {
  
say2
  Light Mouse made by Steve2
#b //Dont change this Line please :P
  
/"colour" to change the colour.#b
  
Colours are redbluewhite,#b
  
yellow,green!#b
  
type "/end" to turn it off,#b
  
to turn it on just set a Colour.#b



Jackel9 12-02-2005 05:42 PM

Wow I remember that one Steve
I was really impressed by that script.=D

Lance 12-02-2005 10:01 PM

Quote:

Originally Posted by steve2
Keep trying and scripting and if u got any Questions about any scripts or such just feel free to post them here :D]

I have a question. What happens when someone tries to use showimg with a noninteger index? Because that's what you're attempting to do, though your line

Quote:

NPC Code:
    this.a = (this.a < 10) ? (this.a + 0.5) : this.a = 0;


isn't quite doing what you think it will.

Dach 12-02-2005 10:11 PM

It should most certainly not be running that timeout when the effect is not to be seen.

Other than that and what Lance said, it's a decent script (construction wise)
*cough*GS2isthewaveofthefuture*cough*

ZeLpH_MyStiK 12-03-2005 08:10 PM

Quote:

Originally Posted by Dach
It should most certainly not be running that timeout when the effect is not to be seen.

Agreed, although, i don't see how it's such an impressive script as Jackel9 said. All it does is show a color changing light where the player's mouse location.

Also toweapons should not be used, even if this script is to be used offline. This certainly would have worked offline without the toweapons.

steve2 12-03-2005 09:13 PM

yes you should read my text :D i said toweapons just for offline test
and that isnt very good i said too but i like effect :P + thats not one of my best....i work as NAT on Shaded Legend right now so if u have questions meet me there!! (and i can scirpt gscript2 because shaded use the engine gscript2, but i did this in gscript1 because people want to test it in editor)

ZeLpH_MyStiK 12-03-2005 10:29 PM

Quote:

Originally Posted by steve2
yes you should read my text

I did.
Quote:

Originally Posted by steve2
i said toweapons just for offline test and that isnt very good

No you did not.

Plus, the script would have worked without toweapons just as a level npc.

Lance 12-04-2005 01:36 AM

Quote:

Originally Posted by steve2
yes you should read my text :D i said toweapons just for offline test
and that isnt very good i said too but i like effect :P + thats not one of my best....i work as NAT on Shaded Legend right now so if u have questions meet me there!! (and i can scirpt gscript2 because shaded use the engine gscript2, but i did this in gscript1 because people want to test it in editor)

So, you do not plan to correct the egregious errors of this script?

Polo 12-04-2005 04:11 AM

Quote:

Originally Posted by Lance
isn't quite doing what you think it will.

Either your post is unclear (to me), or you see an alternate interpretation of this statement. To me I only see one interpretation, and a quick check in the editor confirms this behaviour (ie: counting in half steps up to 10, then reseting). The multiplication with 'i' to give it its indexes leads to some nice patternal behaviour (1,3,6,10,15 etc..) on the first loop, and an alternate series of integers on the second loop through.

On the 3rd and 4th loops however, half the values have a .5 offset (and shouldn't be valid image indexes), is this what you are referring to Lance?

Asside:
Note that the above '.5' issue can be fixed by changing the case to <=, as this then ensures that the lengths of both 'counted loops' are both even, and the value will (in this case), always be even. Or change it to < 9.5, and then not only are they both even, but they are also both mulitples of eachother, which has other interesting properties.

Lance 12-04-2005 04:23 AM

Quote:

Originally Posted by Polo
Either your post is unclear (to me), or you see an alternate interpretation of this statement. To me I only see one interpretation, and a quick check in the editor confirms this behaviour (ie: counting in half steps up to 10, then reseting). The multiplication with 'i' to give it its indexes leads to some nice patternal behaviour (1,3,6,10,15 etc..) on the first loop, and an alternate series of integers on the second loop through.

On the 3rd and 4th loops however, half the values have a .5 offset (and shouldn't be valid image indexes), is this what you are referring to Lance?

Asside:
Note that the above '.5' issue can be fixed by changing the case to <=, as this then ensures that the lengths of both 'counted loops' are multiples of eachother, and the value will (in this case), always be even.

Other than the noninteger image index problem,

NPC Code:
this.a = (this.a < 10) ? (this.a + 0.5) : this.a = 0;


Should be:
NPC Code:
this.a = (this.a < 10) ? (this.a + 0.5) : 0;


steve2 12-04-2005 03:03 PM

no :D no time to clear errors people who cant scirpt could just learn some stuff about light and lightpositions of it :P i got a lot of work on SL right now probably later

ZeLpH_MyStiK 12-04-2005 05:48 PM

Quote:

Originally Posted by steve2
no :D no time to clear errors people who cant scirpt could just learn some stuff about light and lightpositions of it :P i got a lot of work on SL right now probably later

Thus you shouldn't post erroneous scripts on the forum for others to learn from.

Lance 12-05-2005 12:37 AM

Quote:

Originally Posted by steve2
no :D no time to clear errors people who cant scirpt could just learn some stuff about light and lightpositions of it :P i got a lot of work on SL right now probably later

Okay. :)

steve2 12-05-2005 08:47 PM

okay :D u could remove this thread if u want xD i just like the effect because if u online and use this weapon other players can see ur mouses in form of this light :P so if many people online there many lights in level flying around lol could be used to show something or such lol but yea u right gscript2 is the future

Raeiphon 12-10-2005 01:08 PM

Uhm, doesnt //#CLIENTSIDE mean that only the single player who is running that script sees it, not everyone else?

xAndrewx 12-10-2005 01:23 PM

yes. Check the showimg
for(i = 0; i < 10; i ++){
this.a = (this.a < 10) ? (this.a + 0.5) : this.a = 0;
showimg this.a * i,light2s.png,mousex,mousey;

If it's below 200, it's serverside.

underwood 03-17-2006 07:06 AM

wow man this is nice


All times are GMT +2. The time now is 05:50 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.