Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Level Design (https://forums.graalonline.com/forums/forumdisplay.php?f=6)
-   -   Need help with lights please. (https://forums.graalonline.com/forums/showthread.php?t=134263955)

water95 07-19-2011 08:37 PM

Need help with lights please.
 
So i'm making a level on the era tileset and I want to add lights to it but I have no idea how. I've asked a bunch of people and all they say is it's an NPC but I don't know what that means. So here is what I do. From my level editor I click Predefined NPCs. I then click on light and set all the numbers to Red:54, Green:31, Blue: 1, and alpha was automatically set to .99. Is their something i'm suppose to add to it and not just click lights. Please, I really need help.

Emera 07-19-2011 09:17 PM

1 Attachment(s)
Drag and drop one of these into your level. You can edit the values of the red, green, blue and alpha on the right before dragging it in. Double click the light after being placed to edit its script.

cbk1994 07-19-2011 09:41 PM

Something like this is generally preferable to the above as it's not using old Gscript. Note that it will only work online.

PHP Code:

function onCreated() {
  
this.dontBlock();
  
this.drawOverPlayer();
}

//#CLIENTSIDE
function onCreated() {
  if (
lighteffectsenabled) {
    
this.setColorEffect(0100.8); // red, green, blue, alpha
  
} else {
    
this.hide();
  }


Give it an image (usually light2.png or light3.png).

Emera 07-19-2011 09:47 PM

Quote:

Originally Posted by cbk1994 (Post 1659474)
Something like this is generally preferable to the above as it's not using old Gscript. Note that it will only work online.

PHP Code:

function onCreated() {
  
this.dontBlock();
}

//#CLIENTSIDE
function onCreated() {
  
this.dontBlock();
  
this.drawOverPlayer();
  
  if (
lighteffectsenabled) {
    
this.setColorEffect(0100.8); // red, green, blue, alpha
  
} else {
    
this.hide();
  }


Give it an image (usually light2.png or light3.png).

Ah sorry. Setting a bad example. The method above if far better than mine. I just thought that if I tried to explain this, he wouldn't know where to put it.

ffcmike 07-19-2011 09:59 PM

Quote:

Originally Posted by cbk1994 (Post 1659474)
Something like this is generally preferable to the above as it's not using old Gscript. Note that it will only work online.

PHP Code:

function onCreated() {
  
this.dontBlock();
}

//#CLIENTSIDE
function onCreated() {
  
this.dontBlock();
  
this.drawOverPlayer();
  
  if (
lighteffectsenabled) {
    
this.setColorEffect(0100.8); // red, green, blue, alpha
  
} else {
    
this.hide();
  }


Give it an image (usually light2.png or light3.png).

Not really that important especially with it only being an example but just for the sake of giving others the idea, if you are using dontblock serverside you don't need to be using it clientside, the same would also apply with drawoverplayer and most of the variable setting functions as the data is synchronised.
In theory it's better to have all of these serverside in the event of it being a static (motionless for example) NPC such as a light, this way it's only the specific variables being sent to clients rather than the script itself, which involves less data transfer.

cbk1994 07-19-2011 10:02 PM

Quote:

Originally Posted by ffcmike (Post 1659477)
Not really that important especially with it only being an example but just for the sake of giving others the idea, if you are using dontblock serverside you don't need to be using it clientside, the same would also apply with drawoverplayer and most of the variable setting functions as the data is synchronised.
In theory it's better to have all of these serverside in the event of it being a static (motionless for example) NPC such as a light, this way it's only the specific variables being sent to clients rather than the script itself, which involves less data transfer.

For some reason I thought that if dontBlock was set serverside it still blocked on clientside. I didn't even know drawOverPlayer existed serverside. Tested it, and you're right. Thanks for the tips :).

ffcmike 07-19-2011 10:32 PM

Quote:

Originally Posted by cbk1994 (Post 1659479)
For some reason I thought that if dontBlock was set serverside it still blocked on clientside. I didn't even know drawOverPlayer existed serverside. Tested it, and you're right. Thanks for the tips :).

It's possible that with the update that was made several months ago to remove "empty" NPCs from serverside memory that these forms of synchronisation no longer work after the onCreated event.
Something else which also no longer appears to work serverside is showimg();.

On a related note, if you have lots of animated lights via timeout it would be better to use a class script, not so much because it improves usability but because then it is only the class which is required to be downloaded the one time, rather than each NPC script being downloaded as part of the level file.

For instance:

Class script -

PHP Code:


//#CLIENTSIDE
function onCreated(){
  if(
this.image == NULL){
    
this.image "light4.png";
  }

  
//red
  
if(this.attr[1] == NULL){
    
this.attr[1] = 1;
  }

  
//green
  
if(this.attr[2] == NULL){
    
this.attr[2] = 0.75;
  }

  
//blue
  
if(this.attr[3] == NULL){
    
this.attr[3] = 0.75;
  }

  
//alpha
  
if(this.attr[4] == NULL){
    
this.attr[4] = 0.5;
  }

  
//zoom
  
if(this.attr[5] == NULL){
    
this.zoom 2;
  }
  else{
    
this.zoom this.attr[5];
  }

  
this.setcoloreffect(this.attr[1], this.attr[2], this.attr[3], this.attr[4]);
  
this.boundary = {this.attr[4] - (this.attr[4] / 5), this.attr[4] + (this.attr[4] / 5)};
  
this.flickerchange this.attr[4] / 10;
  
this.onTimeout();
}

function 
onTimeout(){
  
this.alpha += this.flickerchange;
  if(
this.alpha in this.boundary){
    
this.flickerchange *= -1;
  }
  
this.setTimer(0.05);


NPC script:

PHP Code:

this.join("levelitem_light_flicker");

function 
onCreated(){

  
//custom light image
  
this.setimg("light2.png");

  
//custom alpha
  
this.attr[4] = 0.25;

  
//neutralise red to make the colour whiter
  
this.attr[1] = 0.75;



water95 07-19-2011 10:43 PM

I cliked the outlined person, and before i put him into my level I set the light preferences and when I put it down still no light, I don't know if i'm doing something wrong and the scripts cbk gave me i don't know how to add them correctly.

water95 07-19-2011 10:55 PM

Ok, so I set the light preferences and dragged the little outlined man. And I also used light2.png and the light came out and turned red and all, but now how do I get rid of the ugly blackness around it?

cbk1994 07-19-2011 11:11 PM

Quote:

Originally Posted by water95 (Post 1659487)
Ok, so I set the light preferences and dragged the little outlined man. And I also used light2.png and the light came out and turned red and all, but now how do I get rid of the ugly blackness around it?

Unless it's absolutely necessary for it to be in GS1, use this instead:

Quote:

Originally Posted by cbk1994 (Post 1659474)
Something like this is generally preferable to the above as it's not using old Gscript. Note that it will only work online.

PHP Code:

function onCreated() {
  
this.dontBlock();
  
this.drawOverPlayer();
}

//#CLIENTSIDE
function onCreated() {
  if (
lighteffectsenabled) {
    
this.setColorEffect(0100.8); // red, green, blue, alpha
  
} else {
    
this.hide();
  }


Give it an image (usually light2.png or light3.png).

If you prefer to stick with GS1, the issue sounds like your alpha is set to 1. Try setting it to 0.9. If that doesn't fix it, post the script.

water95 07-20-2011 01:53 AM

oh wow it worked! thank you so much


All times are GMT +2. The time now is 01:34 AM.

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