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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Interpreter that works for mobile devices?

Discussion in 'Scripting' started by Mornedil, Aug 20, 2016.

  1. Mornedil

    Mornedil

    Joined:
    Feb 7, 2016
    Posts:
    19
    I'm not experienced enough to write my own interpreter, so I'm wondering if there are any out there that works for mobile devices?

    I've found the Jurassic Javascript Interpreter, although when trying the example project for my android device, it crashed instantly on launch. (It worked on PC). If it only worked it would be perfect, so I'm looking for something similar to that, although it doesn't necessarily have to be Javascript.

    Edit: Sorry if this is in the wrong section, first post on these forums, and the post itself took a bit of a different turn than I had in mind to begin with.
     
    Last edited: Aug 20, 2016
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Worth pointing out that run time interpretation is against the iOS terms of service. You can probably find something that works on android, but nothing for the Apple market.
     
    image28 and Mornedil like this.
  3. Mornedil

    Mornedil

    Joined:
    Feb 7, 2016
    Posts:
    19
    Thank you, I recall reading about that earlier while searching about the subject. Not much I can do about iOS ToS however, so I'm happy as long as it works for android. (well, unless I make my idea work without using an interpreter)

    The idea is basically that players will give their own behaviors to game objects by using a UI, so they won't actually be writing any code themselves, mostly just assign conditions with corresponding actions. I figured it would be easiest to simply output a string from which UI buttons the player has pressed, and then interpret it to perform actions.
    The string could potentially be something like this:
    "if y <= 10 && jumpButton == 1 { jump(25) }"
    And then the game object would jump with a speed of 25 when the conditions are met.

    While on the subject of going against iOS ToS, where exactly is the line drawn? I could (with some trouble) potentially make my own function that evaluates a string and then runs different functions depending on the text. Most basic example would be if the text reads "lol" and the game runs a function to make a laughing sound. But a bit more advanced and it could evaluate a pseudo if-statement and then perform actions depending on the outcome.. would that break the ToS?
     
    Last edited: Aug 21, 2016
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I haven't ever worked directly with Apple, so I'm not sure exactly where the line is.

    Have you tried something like LUA? It's a reasonably popular 'in game' language, and there are plugins around for Unity.
     
  5. Mornedil

    Mornedil

    Joined:
    Feb 7, 2016
    Posts:
    19
    I looked for more info about the iOS terms of service regarding interpreters, and I read that they do allow them under certain circumstances, as long as the interpreted code is either comes with the app or is written by the user, and the app doesn't download any code. Not sure how accurate it is, but from what I understood using an interpreter may not always be a violation of the iOS ToS.

    Yeah, I've written a few things in lua, so I am familiar with it, although I'm not sure if it would be the best for this project.
    But I found something called Freedom Script while searching around a bit more. From the description, it sounds exactly like what I've been looking for! I just hope it works for mobile devices and is as good as it seems.

    What really caught my attention with FS was:
    "You define the language dynamically. Don't force yourself or your users to use scripting languages that are molded or 'Translated' to work with Unity. In Freedom Script the keywords you define directly call a function in your unity scripts! Define as many or as little as you want."