Not signed in (Sign In)

Discussion Tag Cloud

Categories

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

    •  
      CommentAuthorbestdani
    • CommentTimeMay 24th 2016 edited
     
    Hello alltogether,

    I decided to create this thread for creating a collection of scripts by me that are not combined with a special SCO, like editor plugins or helper classes, this distinguishes this thread from my object collection thread.

    The scripts can be found in this Dropbox directory.

    I've currently added a small helper class that uses a new feature (2.2.4.2 beta) which allows opening and reading text files:

    The class reads values for options in a simple config file format to configure scripts without touching the script itself.
    The usage should be hopefully straight forward for those with basic NL2 scripting / general programming experiences, a simple example is included.
    Get it from here.

    I'm planning to include this in my future objects / rides and maybe update some of my already made objects and maybe some of you also want to do this.
    My hope is that it increase usability for objects and scripts because it is not required to edit a script directly to configure its behaviour to some extent.

    As always, feel free to post suggestions or share own improvements.

    Edit:
    A screenshot of a possible application example ;-)
    •  
      CommentAuthorrcth
    • CommentTimeMay 27th 2016
     
    Well done Daniel! :D The configs are opening a whole lot of new possibilities.

    I haven't checked it yet, but is it also possible to save to a config file instead of only reading it?
    •  
      CommentAuthorbestdani
    • CommentTimeMay 27th 2016
     
    No, but I'm not sure if I would be happy if the NL2 API would allow to write files because I think this could be a potential security risk although I agree that you also could do interesting things with that possibilty - not neccesarily with configs, I'm currently experimenting with other potential amazing stuff you can do by reading files.

    For configs there will be at least always the possibility to print a config in the console where you could copy a config from and if I remember correctly the console output is automatically written in a log file somwhere in NL2's application data directory.
    •  
      CommentAuthorrcth
    • CommentTimeMay 28th 2016
     
    If it would be possible to write to a config file, one could save a 'state'. Positions of certain objects (if moved) for example. Who knows, maybe if a train is stored or on-track.
    •  
      CommentAuthorbestdani
    • CommentTimeAug 11th 2016 edited
     
    I have tested an idea that was in my head for some time which I think will open many funny and for some maybe even useful possibilities. Because NL2 scripts can read binary and text files for some NL2 versions I used a intermediate file to communicate with another application on my PC.

    Watch a demonstration on youtube
    (click to watch the video on YouTube)

    The MIDI input from the nanoKONTROL2 device is handled by a python script using pygame and written to a binary file which the NL2 script reads and evaluates. For demonstration it sets the weather values of NL2.

    I think this technique allows very crazy, maybe even useful things in NL2. Using MIDI / gamepad / smartphone input to control coasters, flatrides, general settings would be no problem as well as "injecting" local weather information in NL2.

    This is the NL2 script used for the demonstration:

    import com.nolimitscoaster.Tools;

    public class BinInput extends com.nolimitscoaster.Script{
    private static final String DEFAULT_FILE = "com";
    private float timer = 0;
    private float MAX = 127.f;

    public bool onInit(){
    return true;
    }

    public void onNextFrame(float tick){
    if(timer > 0.1f){
    byte[] data = Tools.loadBinaryFile(DEFAULT_FILE);
    sim.setRainIntensity (data[0]/MAX);
    sim.setSnowIntensity (data[1]/MAX);
    sim.setFogIntensity (data[2]/MAX);
    sim.setWindIntensity (data[3]/MAX);
    sim.setOvercastIntensity(data[4]/MAX);
    sim.setCloudIntensity (data[5]/MAX);
    sim.setThunderIntensity (data[6]/MAX);
    timer = 0.f;
    }
    timer += tick;
    }
    }
    •  
      CommentAuthorbestdani
    • CommentTimeNov 3rd 2016 edited
     
    I thought it could be useful to share a distribution package of the scripts from this discussion.

    A very simple Python and NL2 script that work together to generate a terrain using a grayscale heightmap (actually only the red channel of a png image is used).

    Heightmap image:


    Generated terrain:


    Usage:

    1. Extract the heightmap.zip content somewhere on your computer.

    2. Save the desired heightmap as "heightmap.png" in the heightmap directory. The image dimension should be 769 * 769 pixels.

    3. Run the "heightmap.exe" file built using py2exe that should work without having additional stuff installed. If you have Python (3.4) and the pillow module installed, you can run "heightmap.py" directly. This simple programm should create / update a binary file (heightmap.bin) which is used by the NL2 script to generate the terrain.

    4. Finally run the NL2 Script in NL2 by clicking "Execute Plugin..." in the "Advanced" tab of the NL2 Editor with your park open. Locate and open the heightmap.nl2script script file in the file browser to execute it. You should now see the new terrain in NL2.

      You can change the base height of the generated terrain and the amplitude at the beginning of the heightmap.nlvm file:

      import com.nolimitscoaster.*;

      public class heightmap{
      public static void main(){
      float base = 1.f;
      float amplitude = 50.f;
      ...

  1.  
    Thank you so much for making this! I really wanted to do this but i didnt have the skills to pull it off. Will be using this alot!
  2.  
    Is it possible to reverse the process and generate a grayscale heightmap from nl2? that would be super helpful for trying to import terrain into a 3d software
  3.  
    I keep getting this error every time i run the plugin:
    C:\Users\James\Documents\com.nolimitscoaster.nolimits2\heightmap\heightmap.png: Invalid Format 'Cannot read PNG-File' (Code: -18)
    Failed file: "C:\Users\James\Documents\com.nolimitscoaster.nolimits2\heightmap\heightmap.png"
    I know it has something to do with the .png file but do you have any clue how to fix it?
    •  
      CommentAuthorbestdani
    • CommentTimeNov 7th 2016 edited
     
    That is a NL2 internal error and nothing that's caused by the NL2 script. The reason that NL2 even has the chance to show this error is that the heightmap.png file is used as a preview image in the file browser, I cannot tell you why it shows this error. Most likely the image file is corrupt for some reason. Was the heightmap.exe / heightmap.py program able to handle the image file correctly?
    •  
      CommentAuthorbestdani
    • CommentTimeFeb 25th 2017 edited
     
    Hi everyone, since after some discussion in the scripting ask thread it turned out that ride cameras also work on keyframed objects I thought it could be useful to have an easy to use script for adding cameras to objects.

    I tried to find a balance between flexibility and ease of use, therefore some configuration has to be done in the script file to use it, this script is targeted for anyone who has basic knowledge in to createding 3d objects and animating them and isn't afraid of changing some configurations inside the script file.

    You will find more detailed instructions in this demo park that comes together with a demo object (blender file is also included):

    Subscribe in Steam
    .

    Dropbox download for non Steam users.
    • CommentAuthorA113
    • CommentTimeFeb 25th 2017
     
    It's great, thanks for putting in the time to make it accessible for everyone! It's a game changer for the sim
    • CommentAuthormuchwoo
    • CommentTimeFeb 26th 2017
     
    As Always amazing work Bestdani! This is really cool and easy to use script.