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 scripting language for your game

Discussion in 'Works In Progress - Archive' started by JoeStrout, Dec 14, 2015.

Thread Status:
Not open for further replies.
  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    A progress report...

    I've finished adding and fixing things for the next release, which I'm calling 1.4. I've been using it for some big projects of my own (like this one), and I'm very pleased with how it has shaped up.

    The next step is to revise the documentation — there are enough new features that this will be a bit of work, but hopefully done today. Then I will prepare and submit a new Asset Store package, including both the updated MiniScript core and the new in-game code editor. I'll be reducing the price to $30 at the same time.

    That's because as soon as I have submitted that package, my next task is to publish the source for the core — in both C# and C++ versions — on GitHub, along with some of the accessory implementations (like the Unix command-line version). And also continue to refine and improve http://miniscript.org, the main site for all this.

    So that's the plan! Asset update submitted probably by Friday; open-sourcing probably by Monday. And then I'll continue to work on my own apps that use/showcase the language, such as the command-line version and Mini Micro, and of course helping all of you integrate into your own Unity (and now Unreal too!) games.

    EDIT: User manual updated. So many parentheses slain... oh, the humanity! :p
     
    Last edited: Jun 5, 2019
    zyzyx likes this.
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Version 1.4 has been submitted! Fingers crossed for quick approval. :)
     
    ratking likes this.
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Version 1.4 is now live! In addition to the brand-new in-game code editor, here are the changes to MiniScript itself:

    - Fixed parsing of expressions where a function returns a map, and then you immediately use the dot operator, when invoking the function without parentheses.

    - Fixed an exception that could occur in the range() intrinsic if given non-numeric arguments.

    - Greatly improved the performance of string replication (string * number) for large repeat values.

    - Added limits to how big a string or list can get in some situations (such as concatenation and replication) that easily spiraled out of control before. To adjust these limits, assign to static properties ValString.maxSize (in characters) and ValList.maxSize (in elements).

    - Fixed a thread safety issue that could cause spurious "undefined identifier" errors when running multiple MiniScripts in different threads.

    - Fixed a bug causing functions with no explicit 'return' statement to sometimes return a spurious value rather than null.

    - Fixed a System.ArgumentException that could occur when using the same key twice in a dictionary literal, or when calling d.push(x) where x is already among the keys of d.

    - Fixed a System.NullReferenceException thrown when trying to print a list containing null.

    - No longer throw a "expression required" compiler error when trying to use null in a list or map literal. (Note: you still can't use null as a map key, but it's a perfectly cromulent value.)

    - Multiplying a list by a negative number no longer throws a System.ArgumentOutOfRangeException (instead, it just returns an empty list).

    - Fixed another ArgumentOutOfRangeException that could occur when trying to take a slice of a string with a negative total length (now returns empty string).

    - Fixed a "Stack empty" exception that could occur when an undefined identifier is used as an argument to a function.

    - Fixed a bug causing map equality tests to fail in some cases where the two maps included recursive references to other maps.

    - Parentheses are no longer required or recommended around the arguments of a function called as a statement -- for example, you can now do: print "Hello world!"

    - Tweaked formatting of numbers when converting to strings. Now displays all integer values in full integer form; uses exponential notation for other numbers > 1E10, or < -1E10, or in the range -1E-6 to 1E6; and for any other numbers, displays in standard notation with 1-6 digits past the decimal place.

    - New string.split(self, delimiter=" ", maxCount=null) method splits a string into a list by delimiter with at most maxCount entries.

    - New list.join(self, delimiter=" ") intrinsic joins a list into a string using the given delimiter.

    - New replace(oldval, newval, maxCount) intrinsic works on strings, lists, and maps; parameters are old value (to be replaced), new value (to replace it with), and optionally a maximum number of replacements to make (if omitted, then all occurrences are replaced). Lists and maps are mutated in place.

    - New log(x, base=10) intrinsic finds the logarithm of the given number with the given base (defaults to 10), i.e., the number y such that base^y == x.

    - Added an "isa" operator for runtime type checking. Usage: `a isa b`, where a is any value, and b is: list, map, number, string, funcRef, or some other map. In the case of maps, this walks the __isa chain as you would expect. Evaluates to 1 if `a` is of the type specified by `b`, or 0 otherwise.

    - Strings now support subtraction, which is the inverse operation of string addition (concatenation): if the left-hand side string ends with the right-hand side string, then the latter is stripped off in the result; otherwise the left-hand string is returned as it is. Example: "foo.txt" - ".txt" == "foo".

    - New intrinsic "version" returns a map containing information about MiniScript and its host app: numeric version of miniscript and host, build date in YYYY-MM-DD format, and host name and info (e.g. URL).

    - New special identifier "super" can be used to invoke a function on the base class, e.g., `super.foo(42)` invokes `foo` on the base class, while keeping `self` bound to the same value as in the current function. ("super" and "self" are pseudo-keywords: technically identifiers, but with special built-in behavior.)

    - Host apps can now set an "assignment override function" on any ValMap, allowing a bit of native code to run when user code assigns a value in that map.

    - Fixed a failure of the "not" operator to work with lists and maps.
     
    zyzyx likes this.
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Don't want to spam my own thread too much :p, but this is so much fun I have to share.

    I'm working recently on Mini Micro, which is an 80s-style virtual computer that uses MiniScript both for the programming language, and for the command language at the prompt. I've just added support for sprites, and added a demo to the /sys/demo directory which is surprisingly fun to play with!



    To try it out:
    1. Go to https://miniscript.org/MiniMicro
    2. Enter
      cd "/sys/demo"
      (the quotation marks are required)
    3. Enter
      load "spriteDemo"
      (required again)
    4. run
    Use the arrow keys to move; press Esc when done. Then, if you like, use the
    edit
    command to monkey with the code!

    Edit: Mini Micro now has its own thread in the Works in Progress forum.
     
    Last edited: Jun 22, 2019
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,581
    cannot copy paste commands.. i think i've seen some threads for workarounds with unity webgl.
     
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Yes, I delved into those here. They don't work for the code editor, because it's not an input field. :( (They work by basically positioning a native input field on top of the Unity one, cleverly matching the font etc. so the user maybe doesn't notice... but since the behavior of a code editor is quite different, they would notice in this case.)

    I could maybe replace the MiniScript code editor entirely with an Ace code editor like used on the Try-It page. That's a possibility for the future. But I still wouldn't have a reliable way to save your code across runs. I could use browser data, but that's likely to be lost when you switch browsers or clean your cache. The only right solution for that would be to save on the server, which means user accounts and logins... bleh.

    For now, the Web version is going to be like the store model: you can dink around on it and run the demos, but it's pretty serious for limited use. What you want is to take one home, i.e., a downloadable version, which is the planned solution (and if anybody wants one before it's officially "ready," just PM me!).
     
  7. ifayad

    ifayad

    Joined:
    Jun 15, 2017
    Posts:
    24
    Hello @JoeStrout , Any chance to include the Mini Micro with the asset ? Is it the same as the command line for Linux/mac ?
     
  8. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    No, Mini Micro is a big app based on MiniScript; it's not part of MiniScript. It also uses several other assets (NativeFileBrowser for example). So I can't include it or open-source it.

    But can I ask why you would want that, anyway? Mini Micro is free, so if you want to play with it you certainly can whether you have the MiniScript asset or not.
     
  9. ifayad

    ifayad

    Joined:
    Jun 15, 2017
    Posts:
    24
    In the game I'm working on, you have a sort of an in game computer. Initially I wanted to only have a shell prompt, so I repurposed a fully fledged command line interpreter, which is an overkill. Then I had the idea of adding a scripting language (that's why I bought miniscript) where users can write code and execute programs to interact with the environment. The computer has a virtual memory system and all the files and data are stored in a document manager (so users don't have access to your real computer). Long story short, after finding that you have a terminal I thought i'd get rid of my command line interpreter and let miniscript handle everything. So I'm just interested in the command line really. If it's the same as the shell that you implemented in c++, I can port it to c#
     
  10. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    OK, first, that sounds awesome, and please keep me posted as your game develops, so I can point MiniScript users to it!

    You should indeed be able to ditch your command line interpreter and let MiniScript do it; that's how Mini Micro works. There are just intrinsics and some automatically-run start up code that define things like cd, clear, etc. The only drawback (if you want to call it that) is that, unlike a typical file shell, you have to use quotation marks around any string arguments (like paths or file names). If that really bugs you, you could have a bit of code that sits between the user's input and the MiniScript interpreter that does this for you.

    So give Mini Micro a try (probably best to discuss that over in its thread), and if there's anything in there that would be useful to your game, PM me and I'll be happy to share it.

    This goes for everyone here — I am eager to help you all embed MiniScript into your games, and make it awesome. I have already worked closely with a couple of developers to help them get the most out of it, and I'm happy to do the same for you. The bigger the MiniScript user community gets, the better it is for all the games that use it!
     
  11. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    MiniScript v1.4.1 is now available in the Asset Store! Changes in this release:
    • Fixed a bug that would cause the `break` keyword to throw a compiler error when used before an `else` block. {GitHub issue #2}
    • The split(delim, maxCount) intrinsic now works with a delimiter of empty string; it splits on individual characters, up to the specified count. (Note that if you don't specify maxCount, then using .values would be equivalent and slightly more efficient.) {#1}
    • Fixed a bug where hasIndex on a list would return true for any string argument {#3}.
    • New list.insert(index, value) intrinsic inserts a new value into a list in place. Also works for strings, though in that case a new string is returned (since strings are immutable). {#4}
    • Fixed inconsistent handling of @ (the address-of operator) on the first token of a statement. Especially seen in a REPL, for example: entering `@rnd` should (and now does) display the function summary rather than actually invoking the function. {#5}
    • When you convert a list or map to a sting, and it contains a reference to some other list or map that is also referred to by a global variable, you now see it as the global variable rather than its contents. This makes it much easier to examine such objects, particularly in object-oriented programming where the __isa chain can otherwise be hard to wade through.
    • Fixed an infinite loop that could occur if you constructed an __isa chain containing a loop.
    This is a recommended update for all MiniScript users.
     
    zyzyx likes this.
  12. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    117
    Hi! I bought your asset last week and looked into it during the weekend. So far I have implemented a code generator, that looks for certain attributes (such as MSClass, MSMethod, MSEnum) from my code and generates both C# and Miniscript APIs for these.

    Next thing on my todo list is to figure out a nice way to reload scripts while the game is still running. This would allow me to leave a scene, modify and reload the scene's scripts, and then re-enter the updated scene. I think this should be possible with the way the interpreters are done.

    Anyway, good job with Miniscript! It is quite fun and intuitive to work with. I'll add a review to Asset Store later once I'm more familiar with Miniscript.
     
    JoeStrout likes this.
  13. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Sounds great! I agree, what you're describing should be quite doable. Have fun, and let me know if you run into any issues!
     
  14. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I just wrote a new blog post explaining some of the rationale behind MiniScript's design:

    Check out the full post, and feel free to comment here or in the MiniScript forums!
     
  15. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    For anybody who's been using MiniScript on the command line — or wanted to, but couldn't because you're on Windows! — I have good news. Command-line MiniScript is now available for all desktop platforms (Mac/Win/Linux)!

    And while it was previously available for Mac and Linux, today's build includes substantial enhancements for them too, particularly related to file handling.

    See the official announcement here, or download it from here.
     
    zyzyx likes this.
  16. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    For all MiniScript users... or potential MiniScript users... or wanna-be-but-haven't-yet-had-the-opportunity-MiniScript-users:

    I'm hosting a MiniScript Rosetta Code contest, with prizes of $25, $15, and $10 for 1st/2nd/3rd place! All you have to do is implement little Rosetta Code programming tasks in MiniScript. Whoever implements the most by October 15th wins!

    Check out the official announcement here, and if you have any questions, don't hesitate to ask. I intend this to be a fun way for people of all skill levels to get some experience with MiniScript, and help fill out Rosetta Code at the same time. So dive in, and have fun!
     
    zyzyx likes this.
  17. kraihd

    kraihd

    Joined:
    Sep 10, 2015
    Posts:
    20
    Are you considering to make this script ready for Burst compiler?
    Burst is a great way for high performance processing (particularly movement of projectiles or enemies), and I guess that it is very synergistic with the concept of MiniScript.
    If realized, it would be defenitely powerful.
     
  18. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I haven't really thought much about how the Burst compiler might be applied to MiniScript. That's an interesting idea!
     
  19. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    One week in, there are still no entries yet in the MiniScript Rosetta Code Contest. This means that if you implement a single task, no matter how simple (like Array Length for example — in MiniScript it's just someList.len), you will be first in line for the $25 prize.

    Surely there's somebody here who has 10 minutes to bang out a line or two of MiniScript code?
     
  20. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    Hey JoeStrout,

    Are their any gotchas with IL2CPP and Miniscript? I'm currently evaluating a few solutions we might make use of to open up our game to modders but we will be deploying to the playstation 4/5 so any tool must be compatible with those platforms.
     
  21. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    No problems as far as I'm aware. MiniScript is pure C# code, so it should work fine.
     
  22. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    Also, how does Miniscript handle memory alllocation/deallocation? Does the user get any control?

    cheers
     
  23. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Not really, no. It uses standard C# memory management. (I'd be interested in exploring optimizations for your needs with you, though.)
     
  24. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    Thanks for your prompt replies Joe. I now feel comfortable enough to buy the asset so we can properly evaluate it. Good to hear you're keen to support it. :)
     
    JoeStrout likes this.
  25. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Sure thing! Two reminders:

    (1) the MiniScript core is open-source; you can plop that into your Unity project and it'll work fine. Purchasing the plug-in just adds an in-game code editor, and throws a little money my way to help support development (which I do appreciate).

    (2) there's a little contest going on right now in which you could win up to $25, and that could be a fun way to familiarize yourself with the language.
     
  26. andreakarasho

    andreakarasho

    Joined:
    Oct 2, 2019
    Posts:
    1
    Hi Joe,
    First of all: nice work!
    I started to make a new one for my game out of unity like ms, but this is super imho.

    I posted some QoL and issues in github page, lemme know what you think about.

    Cheers
     
    JoeStrout likes this.
  27. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Thank you! I really appreciate the contributions. And I can't wait to see what you're doing with it!
     
  28. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    177
  29. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    177
    Also - unrelated - I'm seeing a few warnings about the code editor. Most are "assigned but not used" but these two are implicit overrides:

    Assets/MiniScript/Miniscript Code Editor/CodeEditor.cs(142,17): warning CS0114: 'CodeEditor.Awake()' hides inherited member 'Selectable.Awake()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
    Assets/MiniScript/Miniscript Code Editor/CodeEditor.cs(152,17): warning CS0114: 'CodeEditor.Start()' hides inherited member 'UIBehaviour.Start()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.


    Should they apply override with a call to the base method, or new?
     
  30. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I have a slightly newer version of the code editor than what was last pushed to the asset store — I'll try to pack that up for you and send a link later today. But Awake and Start should both have be `override`. (And I'm not actually calling the base class method, but you're right, I probably should!)

    As for how to create intrinsic MiniScript classes in C#, you just make a ValMap and stuff some methods into it. For example, here's the code for the "mouse" module in Mini Micro:

    Code (CSharp):
    1.     static ValMap mouseModule;
    2.     static ValMap MouseModule() {
    3.         if (mouseModule != null) return mouseModule;
    4.         mouseModule = new ValMap();
    5.         mouseModule.map[_x] = ValNumber.zero;
    6.         mouseModule.map[_y] = ValNumber.zero;
    7.         mouseModule.assignOverride = DisallowAllAssignment;
    8.  
    9.         Intrinsic f;    
    10.  
    11.         // mouse.button
    12.         f = Intrinsic.Create("");
    13.         f.AddParam("which", ValNumber.zero);
    14.         f.code = (context, partialResult) => {
    15.             int buttonNum = context.GetVar("which").IntValue();
    16.             return Input.GetMouseButton(buttonNum) ? Intrinsic.Result.True : Intrinsic.Result.False;
    17.         };
    18.         mouseModule["button"] = f.GetFunc();
    19.      
    20.         // mouse.visible
    21.         f = Intrinsic.Create("");
    22.         f.code = (context, partialResult) => {
    23.             return Cursor.visible ? Intrinsic.Result.True : Intrinsic.Result.False;
    24.         };
    25.         mouseModule["visible"] = f.GetFunc();    
    26.      
    27.         mouseModule.assignOverride = (key, value) => {        
    28.             if (key.ToString() == "visible") Cursor.visible = MiniscriptUtils.ToBool(value);
    29.             return true;
    30.         };
    31.         return mouseModule;
    32.     }
    The mouse.button intrinsic is a pretty typical method which takes a parameter and returns a result. mouse.visible is similar but needs no parameter. And then I'm using the assignOverride trick so that, if the user assigns a new value to mouse.visible, we intercept that and do the right thing.

    All this is a static ValMap, which gets returned from a "mouse" intrinsic defined with my other global intrinsics:

    Code (CSharp):
    1.         f = Intrinsic.Create("mouse");
    2.         f.code = (context, partialResult) => {
    3.             return new Intrinsic.Result(MouseModule());
    4.         };
    I'm calling this a "module" because it's not intended for users to derive from it with new. But keep in mind that in MiniScript, classes and modules are just maps — the only difference is in how you use them. So if you want to make something that is really a class (like Sprite or Bounds in Mini Micro), it's exactly the same under the hood.

    (As a convention, I've settled on capitalizing maps that are intended to be used as classes, but leaving modules lower-case. Following this convention or not is of course up to you.)
     
    Last edited: Oct 6, 2019
  31. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    177
    Got it - that makes sense. Yes, I'm leaning on your mouse example heavily - I'm actually returning a map/class instance from one of the module functions and wondered if I need to mark it as a class in some way in case someone wants to use IsA on it or what have you.
     
    JoeStrout likes this.
  32. fup

    fup

    Joined:
    Jan 18, 2016
    Posts:
    76
    Hi again Joe,

    I don't see a debugger in the package. This would likely be a deal breaker for us. Are there any plans for one?
     
  33. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    You're right, there is no debugger. It's not in the near-term plans, though it's definitely on the "someday" list. And of course the core is open-source, so if you want to contribute, I'd be happy to work with you on it!

    Most the data you'd need to make a debugger is there: the VM can be paused at any point, and you can get to the call stack and the local variables. We'd probably need to add a little bit more to the compiled code to make it easier to map back to source (a little tricky since MiniScript is not inherently file-based; you feed it source as strings from wherever). But all potentially doable.
     
    zyzyx likes this.
  34. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Hey all, I just want to point out that there is still one week left in the MiniScript Rosetta Code Contest. This is a little contest to see who can implement the most Rosetta Code tasks, in MiniScript, before October 15th. The winner (currently standing at 3 tasks) gets a US$25 gift certificate, with $15 and $10 for 2nd and 3rd place.

    There are still a lot of very easy tasks left, so if you have any interest in MiniScript, you should give it a try! (And if you don't, why are you here? ;) ) It's a chance to have some fun, stretch your MiniScript knowledge, and contribute to the MiniScript community all at the same time. Check it out, and feel free to PM me with any questions!
     
  35. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    177
    Hey Joe,

    Making great progress over here thanks to your superb mouseModule example. Have a basic game loop up and running, that's actually controlled by Miniscript user scripts. So that's nice.

    For the next bit I want to make a Minscript callback/handler that Unity/C# invokes when the player dies.

    So, for example, on the Minscript side:

    Code (JavaScript):
    1. onDied = function(player)
    2.   print "Boo hoo - player died - " + player.name + "!!"
    3. end function
    4.  
    5. playerModule.died.addListener (onDied)
    Can you please give me some pointers on this?
     
  36. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I believe that chapter 4 of the integration guide, "Making an Event Handler," would apply in this case. You can see this demonstrated in the EventPumpDemo included with the asset.

    Just keep in mind that for this to work, the user code needs to actually proceed to its end (where you have sneakily appended the event loop code). If user code goes into an infinite loop of some sort, then it won't be receiving events. I'm not sure it makes sense for it to behave any other way, but if it's problematic for your use case, we could certainly brainstorm ideas.
     
  37. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    177
    Wow - thanks for the almost instant reply.

    Yes, chapter 4 of the integration guide is just what I need. I knew I'd seen it somewhere - thanks for the pointer.

    Good point given your comment about proceeding to the end. In my case, it would probably be easier in that case to have a separate script for this - I have the main loop executing on a timer and calling GameOver at the end, but there's no reason I couldn't have another "Events" script which defines the events being called back.

    Nice one, Joe. This stuff is so cool.
     
    JoeStrout likes this.
  38. BinaryZERO

    BinaryZERO

    Joined:
    Jul 16, 2012
    Posts:
    5
    Hi, MiniScript looks very promising and I am interested to buy it. It seems MiniScript has no issue with ahead-of-time platforms like IOS which is important for me. MiniScript would be a suitable tool for adding modding support for my upcoming role-playing & card game for mobile & pc. I would love to use MiniScript to define moddable NPCs, interactable items, quests, dialogues, and in-game-cutscenes so modders could add/remove/modify any narrative content for their needs (they could not modify the core game loop since it will be still hardcoded). I explored the documentation beforehand to check if it is suitable for my needs, but I am confused with the variables created inside MiniScript. For example, I need to create/store all variables for all NPCs in MiniScript user scripts and need to store/reload these variable states when the player save/load their game progress. It even would be better if variables/objects could be tagged as public/serializable/etc... but I guess I can force a rule through variable names manually.
    • Since these user scripts can be completely rewritten by the modders how can I create a save/load system that supports this list of variables? I only saw
      interpreter.Get/SetGlobalValue
      in the documentation which can't give me a full list.
    • I also need a list of global objects too... Do they count as variables too?
    • How does the global object/variable referencing between separate user scripts files work? (defining a global object/variable in a file and use it in another file)
    • Does every user script always loaded in runtime or can I manage/restrict user scripts that are loaded/unloaded? I expect massive amounts of these scripts in the game. I didn't see any reference to this issue in both documents...
    I am thrilled to buy and try after finding answers to these questions. I used Lua several years ago and don't want to return the ugly Lua and this looks much cleaner. Keep up the nice work!
     
    Havokki and JoeStrout like this.
  39. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    You can certainly get at all the global variables (Interpreter.vm.globalContext.variables will do it). Yes, globals are just variables.

    Sharing data (such as globals) between different scripts is doable, though a little thorny. I would be happy to work with you to figure out the best solution for your use case. It might be, for example, that what you really want is a shared map (i.e. dictionary) which exists in the global space of multiple scripts; that's easy enough to arrange. You could have multiple scripts actually share globals too, though I think this might get confusing for the users.

    Scripts don't just magically load themselves; you write code to load and run any script. So how and when you do that is up to you.

    I try hard these days not to express my true feelings about Lua. :p But, this side by side comparison of Rosetta Code tasks makes for a fun read.

    Be sure to check out the MiniScript forums, and feel free to PM me (in either place!) with any more questions or requests. I'm always happy to help!
     
    Havokki likes this.
  40. BinaryZERO

    BinaryZERO

    Joined:
    Jul 16, 2012
    Posts:
    5
    Thank you @JoeStrout! Loading them individually is good as long as they can be unloaded too... And
    Interpreter.vm.globalContext.variables
    is an important thing to know, and I would recommend you put it in the integration manual.

    I also think I get what you mean by a shared dictionary. I guess you are offering to implement an Intrinsic function that access/register to a C# dictionary that also handles de/serialization. I agree that would be a straight forward solution for my case. Yet, I am wishing for a solution that would auto-completes these shared variable names since I expect hundreds of them. They would be so bothering to keep track especially while writing triggered events/cutscene scripts because they would require checking parameters/variables of different NPCs, Interactive objects, global game flags, etc. If all of these will be used just as a string parameter of that Intrinsic functıon (ex: loadVariable), it will be very discouraging to go and check for their exact names every time you need them. Do you have any easy/smart solution idea for this?

    I already decided to buy MiniScript but I still would love to hear your ideas! Thanks again for your detailed answer. I will definitely use MiniScript forums next time. Cheers!
     
  41. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I was actually thinking of a MiniScript map, not any old C# dictionary. Such a map has a C# dictionary under the hood, though, and in your C# code you can access and manipulate that as needed.

    When talking about autocomplete, do you mean in your C# code, or in the runtime code editor you provide to your users? I think maybe the issue is: you have a whole bunch of C# classes that you want to provide to the MiniScript code, but of course in C#, you want to use "real" properties, not access values through a dictionary by magic strings.

    There are at least a couple different ways to approach that, based on where the values "live" (i.e. where the data is actually stored). You could have them be native MiniScript objects, with all their property values stored in a ValMap, but provide C# wrappers for these that use computed properties to get/set those values. So this way MiniScript accesses them directly, and your C# code indirectly, but thanks to the computed properties they will be no harder to use than ordinary C# objects.

    Or you could do the opposite: have the values stored as native C# values, and provide accessor methods (and use assignOverride) to allow the MiniScript code to get/set them. This is mostly what I've done in Mini Micro.

    Once you have MiniScript on hand, I would encourage you to experiment and try it both ways on a small scale. You'll end up with a much clearer idea of which approach works better, and how to move forward.
     
  42. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I've set up a MiniScript Discord Server for real-time chat among the MiniScript community. Join it here:


    This supplements the MiniScript Forums, which is a better place for longer posts, or anything you want to stick around and be searchable, etc. But Discord is a great place for quicker answers, back-and-forth troubleshooting, and general hanging out with other MiniScript users.

    Come join us! We're a friendly bunch. :)
     
    Colin_MacLeod and zyzyx like this.
  43. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Hi all! A few fun announcements for today:
    1. MiniScript version 1.5 is complete, and has a whole host of improvements over the last official release. This will be submitted to the Asset Store in the next few days, and should be available in about a week.
    2. Mini Micro version 0.8 was just released yesterday. This is the neo-retro home computer based on MiniScript, and is a fun way to get more experienced in the language. Check out the official announcement here.
    3. You can now flex your MiniScript skills and earn MiniScript badges! This is a fun way to check your mastery of the language. If you're using MiniScript in your own games, you can point your players here as another way to challenge themselves and gamify their learning, so they can play your game even better. Give it a try!
    Cheers,
    - Joe
     
  44. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    MiniScript v1.5 is now live in the Asset Store! This includes all the improvements to the language itself (detailed here), plus a host of small improvements to the code editor, which is available only via this asset. Full source code is included.

    If you want to give it a try, check out the web demo and Robo-Reindeer Rumble, both of which were freshly built with the latest version of the asset.

    This is a recommended (and free!) upgrade for all existing owners of the asset.

    Please note: while MiniScript itself doesn't require TextMeshPro — and even the code editor could be made to work without it, in principle — the demo scenes all use it. And it seems that Unity gets quite confused if you import the asset before it has the TMPro classes to resolve against. So for best results, please import the TMPro Essentials before importing this asset.

    If you have any questions or concerns, post here or in the MiniScript Forums, or catch me on our Discord server. Have fun, and make cool stuff!
     
  45. qvinh222

    qvinh222

    Joined:
    Jul 3, 2019
    Posts:
    2
    Colin_MacLeod, Havokki and JoeStrout like this.
  46. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
  47. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    I've been working hard on version 0.9 of Mini Micro, and it is almost done. Part of that has been making some new demos to include with it, like this one:



    ...and this one:



    Just thought I'd share. :) I expect to have it all wrapped up and ready to ship in about a week!
     
    Dave-Carlile and zyzyx like this.
  48. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    A new MiniScript-based project has just launched a KickStarter campaign: Gamelodge!

    Gamelodge is a game development environment and ecosystem. It features online live coding, i.e. you can create and change the game while you and other players are in it!

    It also has a really cool record & playback feature. Your last play-through is automatically saved and can be replayed while you change the camera angle to get a better view, which is great for debugging (and also for making promo videos!). You can even change the scripts or scene, and then replay the recording to see if you've fixed the problem!

    I'm super excited about this. Success of one MiniScript project is success for us all. So please back Brendan's project if you can! (And when your own MiniScript-based project is ready to announce, be sure to let me know!)
     
    zyzyx likes this.
  49. Gray_FoxWare

    Gray_FoxWare

    Joined:
    Jan 31, 2019
    Posts:
    9
    Hey just wondering if miniScript is useable in android and ios?
     
  50. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,833
    Yes, absolutely. It is pure C#, so usable anywhere Unity runs.
     
Thread Status:
Not open for further replies.