Not signed in (Sign In)

Discussion Tag Cloud

Categories

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

    •  
      CommentAuthornolimiters
    • CommentTimeAug 24th 2017
     
    ^ I would like to know that too!
    •  
      CommentAuthorbestdani
    • CommentTimeAug 24th 2017 edited
     

    /**
    * Save as: AttachToRail.nlvm
    *
    * Attaches a scene object to a coaster rail when the scene object uses
    * this script.
    * Enter "update" (without quotes) as the object name in its property dialoge
    * inside the NL2 Editor to move it with the coaster track on transfer tables,
    * switches and so on.
    */
    import com.nolimitscoaster.*;

    public class AttachToRail extends Script{
    private static final float TRACK_SEARCH_RADIUS = 3.0f;
    private static final String UPDATE_KEYWORD = "update";

    private SceneObject sco;
    private TrackPos trackPos;

    public final bool onInit(){
    sco = sim.getSceneObjectForEntityId(getParentEntityId());
    if(sco == null){
    System.throwRuntimeException(
    "This script has to be attached to a Scene Object!"
    );
    }

    trackPos = sim.findNearestCoasterTrack(
    sco.getTranslation(), TRACK_SEARCH_RADIUS
    );
    if(trackPos == null){
    System.throwRuntimeException(
    "Could not find a coaster track within a "
    + TRACK_SEARCH_RADIUS
    + "m range!"
    );
    }

    sco.setMatrix(trackPos.getCenterRailsMatrix());

    bool doUpdatePerFrame = sco.getName().equals(UPDATE_KEYWORD);
    return doUpdatePerFrame;
    }

    public final void onNextFrame(float tick){
    sco.setMatrix(trackPos.getCenterRailsMatrix());
    }
    }
  1.  
    Thank you!
    •  
      CommentAuthornolimiters
    • CommentTimeAug 24th 2017 edited
     
    Thanks for the script!
    But it doesn't work for me. I attached the "AttachToRail.nlvm" to the object in the NL2SCO editor. And named the object "update" in the Scene Object Instance Properties.
    Placed the object within the range of the track. But when the trackswitch moves, the object doesn't move with it.

    EDIT: FIXED It doen't work because of multiple instance, which not all used as a moving object.

    EDIT 2: But I have placement problems now, it appears at a different spot then where I placed it in the Editor.
  2.  
    you will have to adjust the position of it with the nlsco editor until its right.
    •  
      CommentAuthornolimiters
    • CommentTimeAug 24th 2017
     
    ^Ahh thanks!
    •  
      CommentAuthorrcth
    • CommentTimeSep 5th 2017
     
    I have a lot of objects in my Blender file and I named them including spaces. However this causes a few problems in NL2 with scripting. If I remove all spaces in a name, my script can find the SceneObjectElement, however it can't with spaces. Am I doing something wrong or is it a NL2 limitation?
    • CommentAuthorMrRC
    • CommentTimeSep 5th 2017
     
    u can use _ (underscore) that does work with NL2.
    •  
      CommentAuthorbestdani
    • CommentTimeSep 5th 2017 edited
     
    ^^ That's not a NL2 limitation or problem. It's what the blender COLLADA exporter does. NL2 can handle elements with white spaces in their names without problems.

    I don't know if this is a COLLADA format specification restriction but blender's COLLADA exporter replaces all white spaces with an underscore as well as the automatically added "." character for example. Anyway if you edit the names in this file manually to restore whitespaces NL2 can handle these without problems.

    I recommend to check the exported element names for example by reimporting the COLLADA file into a new blender session, or using a model inspector (the NL2SCO clipping menu works fine to check this):
    http://i.imgur.com/Fl2UaqT.png

    Really ugly things happen by the way when you have the same name with one time with white spaces and one time with underscores (nobody would hopefully do this for practical purposes), the exporter will then replace the characters and not check if this name already exists.
    •  
      CommentAuthorrcth
    • CommentTimeSep 6th 2017
     
    Okay thank you for the answers. I'll remember that for the next time.
    • CommentAuthoriHack97
    • CommentTimeSep 14th 2017
     
    I know that nl2 scripting is pretty similar to Java/C++, but i'm still wondering what I should learn to use Telemetry
  3.  
    ^Java
    •  
      CommentAuthorrcth
    • CommentTimeSep 15th 2017 edited
     
    There's a Java example for the telemetry server.

    Also, NL2 scripting engine is more C# than C++. :P