Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

MiniScript: lightweight runtime scripting for your Unity games

Discussion in 'Assets and Asset Store' started by JoeStrout, Jul 5, 2021.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,819
    This is the official discussion thread for MiniScript (continuing from the old work-in-progress thread which is now locked).

    MiniScript is a lightweight, simple-but-sophisticated scripting language implemented in plain C#. It is very easy to integrate into your Unity game, enabling things like modding or runtime scripting.

    Handy links:
    I'm passionate about MiniScript, and support my users enthusiastically. Use this thread (or our Discord server if preferred) to ask questions, show off what you're working on, or otherwise share with the MiniScript community, and I will get back to you ASAP!
     
    TrentSterling likes this.
  2. TeacherMax

    TeacherMax

    Joined:
    Jan 27, 2019
    Posts:
    7
    I'm very interested in implementing scripting in Unity this - so cloned the GitHub repo, copied what I think are the right files into a Unity project's asset folder, copy and pasted some code from the Miniscript Unity Integration Guide - and kinda got stuck there...
    what I would find really useful is a step by step what to put where, with a new empty Unity project - maybe with a script that moves a cube around or something really simple.
    I'm reluctant to buy the Asset from the asset store at teh moment as I can't really see how to get it working simply - and I'm not sure if the asset version would make it any easier?
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,819
    Well it definitely would, because the asset includes several sample scenes that do exactly that. This includes the source code for this demo as well as a (slightly older/simpler) version of Robo Reindeer Rumble.

    It should be possible to get going with just the Integration Guide, however. Chapter 2 shows how to get data in and out of a script, by accessing the script's globals or by adding custom intrinsic functions. So you just do that, in Update or FixedUpdate of a MonoBehaviour, tying some of that data to (say) the position of a cube.

    Why don't you post more info about where you are stuck, and I'll see if I can help? Or for faster help, join the MiniScript Discord server; we have a whole channel (#embedders) dedicated to people embedding MiniScript in other apps.
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,819
    Support and discussion of MiniScript has mostly moved into the Discord server, which is quite active, as well as the forums (somewhat less so). But questions/comments are still quite welcome here.

    I have a request myself: if you are using MiniScript in a product, and there is any published article, blog post, press release, etc. about that product, could you please let me know? If it mentions MiniScript then I will want to include it in this wiki page, and eventually it may become a citation in Wikipedia.

    Thank you, and happy coding!
     
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,819
    Hey, MiniScript users!

    The addition of "math-assignment operators" (+=, -=, etc.) is a fairly common feature request. Enough so that I'm now on the fence about whether to add them to the language.

    Please see this blog post, and at the bottom, use the survey form to let me know what you think!
     
  6. pjbaron

    pjbaron

    Joined:
    Jan 12, 2017
    Posts:
    51
    Is there any chance you might eventually migrate ValMap away from the Dictionary type in C#?
    I tried to set up some simple Unity bots controlled by miniscript (using the Asset Store version) and found it had regular major Garbage Collection hitches making it unsuitable for my concept. After some deep profiling I kept coming back to the ValMap use of Dictionary as the probable cause.
    I wrote overloads to reuse existing Dictionary objects where possible, but this only reduced the frequency.
    Unfortunately, when using Unity objects ValMap seems like the only suitable option for Vector3 and Quaternion data exchanges.
     
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,819
    You can make a "ValWrapper" class to let you wrap arbitrary internal C# classes, or similar custom Value subclasses for struct types like Vector3 and Quaternion. Making those as pleasant to use as a map would be a lot of work, but it may be worth it if you're dealing with a lot of vectors and quaternions in your code.

    For ValWrapper, look at the source code to the Farmtronics plugin, specifically the very bottom of M1API.cs at https://github.com/JoeStrout/Farmtronics/blob/main/Farmtronics/M1/M1API.cs . Mini Micro uses the same ValWrapper to wrap things like AudioClip and Texture2D (presented to the user as Sound and Image, respectively).

    For making a custom Vector or Quaternion type that avoids the map, probably better catch me on discord (you can find the link at https://miniscript.org), and we'll work on it together. However there is still going to be some garbage, as all MiniScript Values are C# objects. In my projects, though, it hasn't been a problem. Again, catch me on Discord and maybe we can figure out together what's going on in your case.
     
    pjbaron likes this.