Not signed in (Sign In)

Discussion Tag Cloud

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorPhyter
    • CommentTimeJan 15th 2014 edited
     
    1. Download: Spinning Emergency Light Park
    2. Extract.
    3. You'll find the files for the Spinning Emergency Light in the "absfiles" folder. In this case you can simply copy the "absfiles" folder and rename it.

    Difficulty Level: Easy
    Effect Level: Awesome!

    The Light Source settings Parent Element property in the NL2SCO editor is an important feature to understand because it is extremely useful for helping to create dynamic lighting effects. Here we have an extremely simple script that gets a handle for the scenery object in order to rotate an element named "reflector" within the .3DS file. The scenery object contains two spotlights, which we could name, get handles for, and manipulate manually in the script if we wanted to. But because we have set the Parent Element property for the two Spot Lights, the lights inherit the rotation of the "reflector" object, making this effect extremely easy to code.

    In order to see what we have done, open the scenery object file in the NL2SCO editor. Go to the Lights tab and double click on one of the lights. You'll see the Parent Element drop down with the element objects that are available. We've selected "reflector" because that's the object we are rotating in the script. You can easily imagine how this could be useful for lighting flat rides and be used to make other cool effects.

    It's an easy one, but beautiful. And extremely useful.

    Enjoy!


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

    public class emergencylight extends Script
    {
    private static final float rotationrate = 5;
    private float y = 0;

    SceneObject sco;
    SceneObjectElement elem;

    public bool onInit()
    {
    //Get handle for scenery object file
    sco = sim.getSceneObjectForEntityId(getParentEntityId());
    if (sco == null)
    {
    System.err.println("No scene object was found.");
    return false;
    }

    //Get handle for reflector element
    elem = sco.getElementForName("reflector");
    if (elem == null)
    {
    System.err.println("No object named 'reflector' was found.");
    return false;
    }

    return true;
    }

    public void onNextFrame(float tick)
    {
    y += rotationrate * sim.getCurSimulationTickSec();
    elem.setRotation(new Vector3f(0,y,0));
    }
    }


    • CommentAuthorAnubisLive
    • CommentTimeJan 15th 2014
     
    Wow it looks great, but now i know nr. 1 reason for lag.... animated lights. This had the same performance (9-10 FPS as Tango Park. Thanks anyway for all your work on the program so far...it's awesome!
    •  
      CommentAuthorPhyter
    • CommentTimeJan 16th 2014
     
    Like everything it depends on the system. I try not to build anything that runs less than 60 FPS on my PC to give enough overhead to slower systems. Obviously I went just a tad overboard with the lights here, you would probably never add this many so close together. And a lot more can be done to optimize the model as well. This is mainly for use as an example how to create such an object. Of course feel free to use it as is if you choose.
    • CommentAuthorReal
    • CommentTimeJan 17th 2014
     
    Scripting is going to primarily draw from a CPU not a GPU. So a stronger CPU here will help you enjoy more scripting. I wouldn't put a lot of stock in mobile cpus either.
    • CommentAuthorole
    • CommentTimeJan 18th 2014
     
    Note that the result of sim.getCurSimulationTickSec() is identical to the tick parameter of onNextFrame method.

    I suggest to change the method to:


    ...
    public void onNextFrame(float tick)
    {
    y += rotationrate * tick;
    elem.setRotation(new Vector3f(0,y,0));
    }
    ...
    • CommentAuthorMGrides
    • CommentTimeApr 15th 2014
     
    THANK YOU! Finally i got a ROTATION with a selfmade, simple object. As you said, Phyter, it´s a simple method to rotate all kind of things in NL2! And especially this fact made me crazy the last couple of days. So i decided to use your "reflector" rotation for a first test. I´m NOT a scripter but got it to work, after i read your descripting and studied the light settings. A small, simple rotation may be not "great" but for me it is a first step into "scripting" =) And it works. I´m amazed! I also changed the part which ole has mentioned. I don´t really understand the difference but i trust him, that it makes sense ;) Now i can build simple flatrides with a rotation.. HOW AWESOME is that!? =D

    Sorry for the bump but i have to say thank you!
    •  
      CommentAuthorggddffhh
    • CommentTimeMay 6th 2014
     
    I am having trouble trying to make that work Phyter. Which file am I putting in the "absfolder" into? I have tried many things, such as copying just the light etc, and it never shows up in my park when I go to scenery etc. Help would be greatly appreciated.
    • CommentAuthorStrazman
    • CommentTimeMay 13th 2014
     
    I absolutely love this script.

    I have one quick question though. How can I change the rotation rate of the light and also it's direction? In other words, how can I change it from rotating clockwise to counter-clockwise or vise-versa?

    I have been going through the script line by line but, as I have zero scripting experience, I can't seem to tweak anything that works.
    • CommentAuthorMarkLB
    • CommentTimeMay 28th 2014
     
    I came accross a very interesting website with more info on this product: http://www.archiexpo.com/architecture-design-manufacturer/emergency-light-1691.html
    •  
      CommentAuthorraptoralex
    • CommentTimeJul 3rd 2014
     
    Posted By: ggddffhhI am having trouble trying to make that work Phyter. Which file am I putting in the "absfolder" into? I have tried many things, such as copying just the light etc, and it never shows up in my park when I go to scenery etc. Help would be greatly appreciated.

    I'm having the same problem. Honestly, this is extraordinarily frustrating. I feel like I can't even begin to understand scripting because I can't access anything I download. I downloaded the file in step 1, but I'm stuck on step 2. How do I extract? I was able to open the file in NL2, but that doesn't appear to extract it. All I can do is open the read-only file and ride it in the simulator.

    That takes me to step 3. I couldn't for the life of me find the absfolder, so I searched in the Start menu. That brought me to Tango Park, and that's the only park with absfolder. The script works in the park you built, but I can't find the files or anything else. What am I doing wrong?
    •  
      CommentAuthoraw555000
    • CommentTimeJul 3rd 2014
     
    Just an FYI, I don't know how to officially "extract" files but I find changing the extension from .nl2pkg to .zip allows you to open the files inside the package including the park file, scenery files, scripts etc.
  1.  
    Posted By: aw555000Just an FYI, I don't know how to officially "extract" files

    >Open package in the editor
    >File>Extract Package...
    >Choose extract location
    • CommentAuthorExz0rs
    • CommentTimeJul 17th 2016
     
    Hey Phyter, im new on this forum but i know most the tricks from nl2. Im now being busy with my spinning coaster, and i love tho have those lights! but the download link is broken, could you help me?





    Sorry for my bad english.

    Exz0rs.
    •  
      CommentAuthorHafizBazzi
    • CommentTimeJul 17th 2016
     
    ^ Way to bump a forum from 2 years ago, but I'll check on my old computer if I have it.
    •  
      CommentAuthorYedrimas
    • CommentTimeJul 17th 2016
     
    • CommentAuthorExz0rs
    • CommentTimeJul 18th 2016
     
    Thanks!
  2.  
    Posted By: HafizBazzi^ Way to bump a forum from 2 years ago


    He had a good reason to bump it.