Discussion in 'Scripts (.NET)' started by MstrGareth, Sep 19, 2007.

  1. MstrGareth

    MstrGareth Active Member

    Messages:
    88
    Is there a way to access the Math TLO from the wrapper?

    Tried testing with lines like

    DebugOut(((int)VGE.VG().GetMember<int>("Math.Calc[10 + 1]")).ToString());

    But no luck so far and I can't the Math TLO listed on the object browser. It's probably something obvious, again :)
  2. tangeleno

    tangeleno Active Member

    Messages:
    7
    Could Use
    Code (Text):

    Ext.VG().GetMember<int>(Convert.ToString(10+1)).ToString();
     
    And not even touch the Math TLO...
  3. MstrGareth

    MstrGareth Active Member

    Messages:
    88
    I am actually needing to access the math TLO for other purposes, I was just using that as a test example.
  4. tangeleno

    tangeleno Active Member

    Messages:
    7
    Ahh, then yeah that wouldn't work for ya. Not seeing it in the DLLs however.
  5. Cr4zyb4rd

    Cr4zyb4rd Active Member

    Messages:
    181
    The math TLO is part of innerspace, so this would be more properly asked on the ismods or lavish forums. That said, the incomplete .NET development wiki http://www.lavishsoft.com/wiki/index.php/IS:.NET#C.23 explains how to get access to any TLO that you like. Poking around at the source of any wrapper should give you the same info...technically a wrapper is just doing this same footwork for you, using the mechanisms for getting at just about any LavishScript object that Lax provides.
  6. Amadeus

    Amadeus The Maestro Staff Member

    Messages:
    8,264
    I'll try and remember to add the Math tlo to the wrapper. It's not an isxvg thing at all, but won't hurt to throw it in there if I can remember to do it.
  7. Lax

    Lax LavishSoft/InnerSpace Guru

    Messages:
    18
    The reason that the Math object is not wrapped in .NET is that it's horribly inefficient compared to doing the same calculation in .NET instead of calling into LavishScript to do it. If you need the distance function for example, it's a lot better to just write the couple lines of code to do it in .NET.

    It goes something like this:
    Code (Text):
    double Distance3D(double x1, double y1, double z1, double x2, double y2, double z2)
    {
      double dX = x2-x1;
      double dY = y2-y1;
      double dZ = z2-z1;
      return Math.Sqrt((dX*dX)+(dY*dY)+(dZ*dZ));
    }
    And that will run much, much faster than calling the LavishScript equivalent. To use the LS function that does the same thing, it's converting those numbers to strings, then back to numbers, then doing the calculation, instead of just doing a couple fairly trivial calculations. I would recommend NOT wrapping the Math TLO.
  8. MstrGareth

    MstrGareth Active Member

    Messages:
    88
    Thanks guys, all very helpful.

    I already went with the custom implementation. My desire to use the TLO is based from a preference to encapsulate the base functionality. In this instance it wasn't very important, but habits are habits :)

Share This Page