Board index Roller Coaster Games NoLimits Coaster 2 NoLimits Coaster 2 Scripting Help! I want to bind lights to an animated object!

Help! I want to bind lights to an animated object!

Post your Nolimits 2 scripts here! Also any discussion regarding scription for NoLimits Coaster 2 should be placed in this forum


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
Basically, I have an animated flat ride that I want to include bound lights when the ride vehicle moves on the tower.

Image


Any help?
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?


Posts: 6183
Points on hand: 483.00 Points
Bank: 19,590.00 Points
I am sorry, but I cannot help you on that issue. Are you making a very small park like my Jamp Up Land park? I'm guessing you got inspired by it.


Posts: 191
Points on hand: 764.00 Points
Very nice idea!!! :D

If you want to attach lights on a moving object, you have to attach the script with the scripted-move -> to the light. I tried that already with the Gyro Tower and it works. You may have to adjust the pivot/center point of the light-object within the NL2editor. I??????ll try that out if it works, i??????ll keep you updated!!!

Ps.: Thank you for your great tutorial-class session! ;)

Nice greetings =)


First Update: I just found out that NoLimits2 lights which attached to a parent object/group in the model, transfer the movements! Let me find the right group and it will be only a few clicks ;)

SOLVED!
Here we go ;) Instead of an extra light, i have used the light directly without any additional objects. So the four extra scripts to follow the movements aren??????t necessary. Good for the performance, easy to make! The parent object is: ARM ;)

SpinningStar-LightAttachment.jpg
Spinning Star - SpotLight attachment!
SpinningStar-LightAttachment.jpg (72.36 KiB) Viewed 3587 times

This is the first light. To add 3 more lights, you only have to adjust the posX and posZ! The second would be -7,3 meter at the posX window. The third: 7,3 posZ andthe fourth: -7,3 posZ. I named the spotlight "thelight1" "...2,3,4". So it??????s possible to turn the lights off during the day circle. I have already adjusted the NL2 "day and night" - light-script for more than one light per object.

import com.nolimitscoaster.*;
import nlvm.math3d.*;

/**
 * This script simulates a simple light, that switches on when the sun sets
 */
public class QuattroLightScript extends Script
{
  private static final String c_aLightSourceName = "thelight1";
  private static final String c_bLightSourceName = "thelight2";
  private static final String c_cLightSourceName = "thelight3";
  private static final String c_dLightSourceName = "thelight4";
  private static final double c_fSwitchOnAngle = 18.0; // degrees
  private static final float c_fMaxInitialDelay = 0.6f; // seconds 
  private static final float c_fSwitchOnTime = 10.0f; // seconds
  private static final float c_fSwitchOffTime = 1.3f; // seconds
  private static final float c_fStartBrightness = 0.2f;

  private SceneObjectLight m_aLight;
  private SceneObjectLight m_bLight;
  private SceneObjectLight m_cLight;
  private SceneObjectLight m_dLight;
  private SceneObject m_aSCO;
  private float m_fInitialDelayTime;
  private float m_fCurBrightness;
  private float m_fNewBrightness;
  private float m_fElevationLimit;
  private Vector3f m_aOrgColor;
  private Vector4f m_aEntCol;
  private bool m_bEnabled;
 
  public bool onInit()
  {
    m_aSCO = sim.getSceneObjectForEntityId(getParentEntityId());
   
    m_aLight = m_aSCO.getLightForName(c_aLightSourceName);
   m_bLight = m_aSCO.getLightForName(c_bLightSourceName);
   m_cLight = m_aSCO.getLightForName(c_cLightSourceName);
    m_dLight = m_aSCO.getLightForName(c_dLightSourceName);
   
    if (m_aLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_aLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_aLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_aLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   if (m_bLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_bLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_bLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   if (m_cLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_cLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_cLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_cLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   if (m_dLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_dLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_dLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
    return true;
  }
 
  public void onNextFrame(float tick)
  {
    bool bEnable = sim.getCurSunElevation() <= m_fElevationLimit;

    if (bEnable != m_bEnabled)
    {
      if (bEnable)
      {
        // switching on
        m_fCurBrightness = c_fStartBrightness;
        m_fNewBrightness = 1.0f;
        m_bEnabled = true;
      }
      else
      {
        // switching off
        m_fNewBrightness = 0.0f;
        m_bEnabled = false;
      }
    }
   
    if (m_fCurBrightness < m_fNewBrightness)
    {
      // switching on
      m_fCurBrightness += tick / c_fSwitchOnTime;
      if (m_fCurBrightness > m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
    else if (m_fCurBrightness > m_fNewBrightness)
    {
      // switching off
      m_fCurBrightness -= tick / c_fSwitchOffTime;
      if (m_fCurBrightness < m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
     
    bEnable = m_fCurBrightness > 0;
   
    m_aLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_aLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
    m_bLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_cLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
    m_cLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_cLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   
   bEnable = m_fCurBrightness > 0;
   
    m_dLight.setEnabled(bEnable);
   
    if (bEnable)
    {
      m_dLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   
    // This controls the fading between normal object color and completely white, using a special material (fade_to_white)
    m_aEntCol.w = m_fCurBrightness;
    m_aSCO.setEntityColor(m_aEntCol);
   }
}

This is the adjusted script for a quattro-lamp. It??????s not ready and i would love if anyone could help me if there is a issue or if it could be easier. But,.. it works! Simply copy&paste this into the win notepad or notepad++ and save it in the "SpinningStar-byfreefall" folder as: QuattroLightScript.nlvm ! After saving, click on the model in the NL2 editor and open the NL2SCO Editor (the model should now be loaded) and go to the Script-Tab. Add here your saved "QuattroLightScript.nlvm" and click on save. Reload the scenery - object aaaaaaaaaaand: It??????s done.

SpinningStar-SpotLightAttachment.jpg
The result!


I hope i could help ;)


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
I followed the instructions, but I'm only getting one small point of light, instead of 4 lights.

Image
Image

Edit: I get this in the message console when I enter play mode. \com.nolimitscoaster.nolimits2\SpinningStar-byfreefall\SpinningStar\quatrolightscript.nlvm : error C14: Invalid class name or package: expected: quatrolightscript in root package, found: QuattroLightScript in root package
...1 error(s), 0 warning(s)


Edit2: I found my own problem.

Edit3: Still having problems. Can You give screen shots for a step by step? I may have missed something.

This is the only light that shows up. On the plus side, it moves with the vehicle.
Image
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?


Posts: 191
Points on hand: 764.00 Points
As i could see, you found the issue with the script =) It was the name which was written in small letters.. but it has to be exactly:

QuattroLightScript

...if you would change the name in the script with small letters, your name would also work ;)


Here are the four light settings:
Step2.jpg
The first light ...
Step2.jpg (50.55 KiB) Viewed 3567 times



Make sure the lights are attached to the right parent object, which can be found in the list:
Step2b.jpg
ATTACHING YAY!
Step2b.jpg (66.15 KiB) Viewed 3567 times



As you can see, the second light having the same settings, except the Pos X ...which is now -7,3 meter!
Step3.jpg
The second light ...
Step3.jpg (46.83 KiB) Viewed 3567 times


The third light has no settings on the X Axis .. but on the Z Axis!
Step4.jpg
The third light ...
Step4.jpg (46.79 KiB) Viewed 3567 times


And the last one is also moved to -7,3 meter on the Pos Z Axis :D
Step5.jpg
The fourth light ...
Step5.jpg (46.81 KiB) Viewed 3567 times


Step1.jpg
All lights with names!

...at the end, you should have these four lights!

Further Tips:
- Make sure you have selected the SPOT not Omni-light!
- If you have the Spotlight selected .. the window for the spotlight will set the light-settings!
Step6.jpg
The settings for the SPOTlight...
Step6.jpg (47.6 KiB) Viewed 3567 times


I hope it??????s working now =)


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
I've got it working!
Image

I found out by accident that I need to restart NL2 after applying all of these changes.


Also, I have the color set as different colors for each vehicle, but they only show up as the color set for "thelight4". Is there any way to fix this?
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?


Posts: 191
Points on hand: 764.00 Points
/o\ ...yes it??????s the script. It??????s not written for multiple colors, since it replaces some materials for the day&night circle. I??????ll look into it later to find a solution!

Looks really cool! Never thought of that idea but it looks really awesome! :D

Nice greetings!

Oscar User avatar
Founding Member
Founding Member

Posts: 14409
Points on hand: 11,944.60 Points
Bank: 187,052.60 Points
Location: California, USA

That looks amazing!
Support Us! - Click Here To Donate $5 Monthly!
Paradox wrote:
No need to tell Oscar about the problems. He is magic.

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Wow! That looks really cool, why hasn't someone done this sooner? Nice job!


Posts: 191
Points on hand: 764.00 Points
Found the issue!
QuattroScript-Reworked-byfreefall.jpg
..now it works!


New Code:
import com.nolimitscoaster.*;
import nlvm.math3d.*;

/**
 * This script simulates a simple light, that switches on when the sun sets
 */
public class QuattroLightScript extends Script
{
  private static final String c_aLightSourceName = "thelight1";
  private static final String c_bLightSourceName = "thelight2";
  private static final String c_cLightSourceName = "thelight3";
  private static final String c_dLightSourceName = "thelight4";
 
  private static final double c_fSwitchOnAngle = 18.0; // degrees
  private static final float c_fMaxInitialDelay = 0.6f; // seconds 
  private static final float c_fSwitchOnTime = 10.0f; // seconds
  private static final float c_fSwitchOffTime = 1.3f; // seconds
  private static final float c_fStartBrightness = 0.2f;

  private SceneObjectLight m_aLight;
  private SceneObjectLight m_bLight;
  private SceneObjectLight m_cLight;
  private SceneObjectLight m_dLight;
 
  private SceneObject m_aSCO;

 
  private float m_fInitialDelayTime;
  private float m_fCurBrightness;
  private float m_fNewBrightness;
  private float m_fElevationLimit;
 
  private Vector3f m_aOrgColor;
  private Vector3f m_bOrgColor;
  private Vector3f m_cOrgColor;
  private Vector3f m_dOrgColor;
 
  private Vector4f m_aEntCol;
  private Vector4f m_bEntCol;
  private Vector4f m_cEntCol;
  private Vector4f m_dEntCol;
 
  private bool m_bEnabled;
 
  public bool onInit()
  {
    m_aSCO = sim.getSceneObjectForEntityId(getParentEntityId());
   
    m_aLight = m_aSCO.getLightForName(c_aLightSourceName);
   m_bLight = m_aSCO.getLightForName(c_bLightSourceName);
   m_cLight = m_aSCO.getLightForName(c_cLightSourceName);
    m_dLight = m_aSCO.getLightForName(c_dLightSourceName);
   
    if (m_aLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_aLightSourceName + "'");
      return false;
    }
   
   
   m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_aLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_aLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   if (m_bLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_bLight.setEnabled(false);
    m_bEnabled = false;
   
    m_bOrgColor = new Vector3f();
    m_bLight.getColor(m_bOrgColor);
   
    m_bEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   if (m_cLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_cLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_cLight.setEnabled(false);
    m_bEnabled = false;
   
   
   
    m_cOrgColor = new Vector3f();
    m_cLight.getColor(m_cOrgColor);
   
    m_cEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   
   if (m_dLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_dLight.setEnabled(false);
    m_bEnabled = false;
   
   
   
    m_dOrgColor = new Vector3f();
    m_dLight.getColor(m_dOrgColor);
   
    m_dEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
    return true;
  }
 
 
 
 
  public void onNextFrame(float tick)
  {
    bool bEnable = sim.getCurSunElevation() <= m_fElevationLimit;

    if (bEnable != m_bEnabled)
    {
      if (bEnable)
      {
        // switching on
        m_fCurBrightness = c_fStartBrightness;
        m_fNewBrightness = 1.0f;
        m_bEnabled = true;
      }
      else
      {
        // switching off
        m_fNewBrightness = 0.0f;
        m_bEnabled = false;
      }
    }
   
    if (m_fCurBrightness < m_fNewBrightness)
    {
      // switching on
      m_fCurBrightness += tick / c_fSwitchOnTime;
      if (m_fCurBrightness > m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
    else if (m_fCurBrightness > m_fNewBrightness)
    {
      // switching off
      m_fCurBrightness -= tick / c_fSwitchOffTime;
      if (m_fCurBrightness < m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
     
    bEnable = m_fCurBrightness > 0;
   
   
   m_aLight.setEnabled(bEnable);
   
    if (bEnable)
    {
      m_aLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
   
   
    m_bLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_bLight.setColor(m_fCurBrightness * m_bOrgColor.x, m_fCurBrightness * m_bOrgColor.y, m_fCurBrightness * m_bOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
   
   
   
    m_cLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_cLight.setColor(m_fCurBrightness * m_cOrgColor.x, m_fCurBrightness * m_cOrgColor.y, m_fCurBrightness * m_cOrgColor.z);
    }
   
   
   
   bEnable = m_fCurBrightness > 0;
   
    m_dLight.setEnabled(bEnable);
   
    if (bEnable)
    {
      m_dLight.setColor(m_fCurBrightness * m_dOrgColor.x, m_fCurBrightness * m_dOrgColor.y, m_fCurBrightness * m_dOrgColor.z);
    }
   
   
    // This controls the fading between normal object color and completely white, using a special material (fade_to_white)
    m_aEntCol.w = m_fCurBrightness;
   m_bEntCol.w = m_fCurBrightness;
   m_cEntCol.w = m_fCurBrightness;
   m_dEntCol.w = m_fCurBrightness;
   
    m_aSCO.setEntityColor(m_aEntCol);

   }
}


PLEASE READ:
I??????m not a coder or scripter =) Maybe there is a way with less lines and a better solution! As for now, it works! :D


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
You are awesome, sir!

Image
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Magu78 wrote:
Found the issue!
QuattroScript-Reworked-byfreefall.jpg


New Code:
import com.nolimitscoaster.*;
import nlvm.math3d.*;

/**
 * This script simulates a simple light, that switches on when the sun sets
 */
public class QuattroLightScript extends Script
{
  private static final String c_aLightSourceName = "thelight1";
  private static final String c_bLightSourceName = "thelight2";
  private static final String c_cLightSourceName = "thelight3";
  private static final String c_dLightSourceName = "thelight4";
 
  private static final double c_fSwitchOnAngle = 18.0; // degrees
  private static final float c_fMaxInitialDelay = 0.6f; // seconds 
  private static final float c_fSwitchOnTime = 10.0f; // seconds
  private static final float c_fSwitchOffTime = 1.3f; // seconds
  private static final float c_fStartBrightness = 0.2f;

  private SceneObjectLight m_aLight;
  private SceneObjectLight m_bLight;
  private SceneObjectLight m_cLight;
  private SceneObjectLight m_dLight;
 
  private SceneObject m_aSCO;

 
  private float m_fInitialDelayTime;
  private float m_fCurBrightness;
  private float m_fNewBrightness;
  private float m_fElevationLimit;
 
  private Vector3f m_aOrgColor;
  private Vector3f m_bOrgColor;
  private Vector3f m_cOrgColor;
  private Vector3f m_dOrgColor;
 
  private Vector4f m_aEntCol;
  private Vector4f m_bEntCol;
  private Vector4f m_cEntCol;
  private Vector4f m_dEntCol;
 
  private bool m_bEnabled;
 
  public bool onInit()
  {
    m_aSCO = sim.getSceneObjectForEntityId(getParentEntityId());
   
    m_aLight = m_aSCO.getLightForName(c_aLightSourceName);
   m_bLight = m_aSCO.getLightForName(c_bLightSourceName);
   m_cLight = m_aSCO.getLightForName(c_cLightSourceName);
    m_dLight = m_aSCO.getLightForName(c_dLightSourceName);
   
    if (m_aLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_aLightSourceName + "'");
      return false;
    }
   
   
   m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_aLight.setEnabled(false);
    m_bEnabled = false;
   
    m_aOrgColor = new Vector3f();
    m_aLight.getColor(m_aOrgColor);
   
    m_aEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   if (m_bLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_bLight.setEnabled(false);
    m_bEnabled = false;
   
    m_bOrgColor = new Vector3f();
    m_bLight.getColor(m_bOrgColor);
   
    m_bEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   if (m_cLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_cLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_cLight.setEnabled(false);
    m_bEnabled = false;
   
   
   
    m_cOrgColor = new Vector3f();
    m_cLight.getColor(m_cOrgColor);
   
    m_cEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
   
   
   if (m_dLight == null)
    {
      System.err.println("Scene object has no light with name '" + c_bLightSourceName + "'");
      return false;
    }
    m_fCurBrightness = 0;
    m_fNewBrightness = 0;
    m_dLight.setEnabled(false);
    m_bEnabled = false;
   
   
   
    m_dOrgColor = new Vector3f();
    m_dLight.getColor(m_dOrgColor);
   
    m_dEntCol = new Vector4f(1,1,1,0);
   
    m_fElevationLimit = (float)Math.toRadians(c_fSwitchOnAngle);
    m_fInitialDelayTime = (float)Math.random() * c_fMaxInitialDelay;
   
    return true;
  }
 
 
 
 
  public void onNextFrame(float tick)
  {
    bool bEnable = sim.getCurSunElevation() <= m_fElevationLimit;

    if (bEnable != m_bEnabled)
    {
      if (bEnable)
      {
        // switching on
        m_fCurBrightness = c_fStartBrightness;
        m_fNewBrightness = 1.0f;
        m_bEnabled = true;
      }
      else
      {
        // switching off
        m_fNewBrightness = 0.0f;
        m_bEnabled = false;
      }
    }
   
    if (m_fCurBrightness < m_fNewBrightness)
    {
      // switching on
      m_fCurBrightness += tick / c_fSwitchOnTime;
      if (m_fCurBrightness > m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
    else if (m_fCurBrightness > m_fNewBrightness)
    {
      // switching off
      m_fCurBrightness -= tick / c_fSwitchOffTime;
      if (m_fCurBrightness < m_fNewBrightness)
      {
        m_fCurBrightness = m_fNewBrightness;
      }
    }
     
    bEnable = m_fCurBrightness > 0;
   
   
   m_aLight.setEnabled(bEnable);
   
    if (bEnable)
    {
      m_aLight.setColor(m_fCurBrightness * m_aOrgColor.x, m_fCurBrightness * m_aOrgColor.y, m_fCurBrightness * m_aOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
   
   
    m_bLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_bLight.setColor(m_fCurBrightness * m_bOrgColor.x, m_fCurBrightness * m_bOrgColor.y, m_fCurBrightness * m_bOrgColor.z);
    }
   
   bEnable = m_fCurBrightness > 0;
   
   
   
   
    m_cLight.setEnabled(bEnable);
   
   
    if (bEnable)
    {
      m_cLight.setColor(m_fCurBrightness * m_cOrgColor.x, m_fCurBrightness * m_cOrgColor.y, m_fCurBrightness * m_cOrgColor.z);
    }
   
   
   
   bEnable = m_fCurBrightness > 0;
   
    m_dLight.setEnabled(bEnable);
   
    if (bEnable)
    {
      m_dLight.setColor(m_fCurBrightness * m_dOrgColor.x, m_fCurBrightness * m_dOrgColor.y, m_fCurBrightness * m_dOrgColor.z);
    }
   
   
    // This controls the fading between normal object color and completely white, using a special material (fade_to_white)
    m_aEntCol.w = m_fCurBrightness;
   m_bEntCol.w = m_fCurBrightness;
   m_cEntCol.w = m_fCurBrightness;
   m_dEntCol.w = m_fCurBrightness;
   
    m_aSCO.setEntityColor(m_aEntCol);

   }
}


PLEASE READ:
I??????m not a coder or scripter =) Maybe there is a way with less lines and a better solution! As for now, it works! :D


Don't worry, anyone that can make stuff like this is definitely a coder or scripter, don't underestimate yourself. You are easily one of the best scripters for this game out there!


Posts: 8144
Points on hand: 13,491.00 Points
Magu, thanks so much for bearing new custom rides and scenery sets! Here I saw your "Super Condor" with the fantastic lights-on! Reminds me of a fiery condor in RCT3! :D
-- I was happy to be with NL1 - [:')] --


Posts: 191
Points on hand: 764.00 Points
Thank you guys =) By the way the original script can be found in NoLimits2. I??????ve only adjusted it to work with more than one light :D But yeah! I shouldn??????t underestimate myself! There are already a lot of work and thoughts gone into those ride =)

@lol240: Yes, it??????s a fantastic idea of NightwindElf! I never thought of that, but it??????s looking really great :D I just have to figure out how the bulps are working so "Tango"lights will be possible in the future =) Would be great to have a small "carnival" feeling on this.

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
I'm learning how to adapt the script for other flat rides!

http://imgur.com/a/6u2Vz
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?

TheArchitect User avatar
Premium Member
Premium Member

Posts: 1331
Points on hand: 501,147.00 Points
Bank: 498,048.00 Points
Location: Dorchester, Dorset, United Kingdom
I cant help but feel that lots of smaller lights would be better. It'll be annoying for people in other parts of the park getting blinded every few seconds, like war of the worlds or something.
Image
Image


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
Lots of smaller lights also intensifies the resource use. The light doesn't go as far as you would think, though.
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points


Posts: 191
Points on hand: 764.00 Points
Nice idea NightwindElf!

Hmm,.. that reminds me of thinking about lights.
It??????s possible, with a few changes to make something like that:
AtmosFear-RainbowsEnd-byfreefall.jpg
(Note: please ignore the distorted light texture on the supports, thanks! ;) )


At the moment i remodel the Gyro Swing and maybe it??????s a good idea to include some "spots" for lights? Or at least a changeable texture where everybody can make some light-patterns with the Light Pattern Creator for the ride?

The lights don??????t cost that much ressources.. and are programm-able. But there are no halo-effects like the spot light.


Posts: 1027
Points on hand: 92.00 Points
Bank: 1,341.05 Points
Sounds like a good idea to me! Some good spots for lights would be on the spokes of the wheel, and around the bottom of the wheel. Maybe even flood lights at the top of the arm?
Originally posted by GerstlCrazy
Cool! The name is Fly Over Rainforest?
I was under the impression the name was Green Coaster Goes Fast Goes High Has Clockwise Loop Has Straight Upside Down Four Seats Two On Each Side Fast Coaster?

TheArchitect User avatar
Premium Member
Premium Member

Posts: 1331
Points on hand: 501,147.00 Points
Bank: 498,048.00 Points
Location: Dorchester, Dorset, United Kingdom
Regarding the performance issues with lights; apparently the issue is when the light is cast on something, causing the engine to generate brighter surfaces and shadows etc. So if you had a few lights actually doing the illuminating, and let the rest of the lights be "effect only", then this can greatly help performance.
Image

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points


Posts: 1703
Points on hand: 35.00 Points
Bank: 4,336.00 Points
Location: Kentucky
What I want to see someone do, Is an animated Hydraulic launch that you can use easily, for the non scripties.

TTD03 User avatar
True Addicts
True Addicts

Posts: 7306
Points on hand: 738.00 Points
Bank: 111,265.11 Points
Closest thing to that is Kyle Sloane's.
See if you can learn from that :/


Return to NoLimits Coaster 2 Scripting

 


  • Related topics
    Replies
    Views
    Last post