- Home /
Programming INSIDE a game?
Hi all! My latest project is a project I am putting together to try to teach programming, specifically the logic of how to think through problems, and how computers know absolutely nothing. So what I am trying to do is make a simple "programming language". Basically just a bunch of global functions that the user can access to make their in game robot do something. I have that part down, however I need help allowing the user to use these functions inside a javascript file without having to decompile the game. Is this possible? I was thinking I could do this via a custom file editor within the game, but even referencing an external file would be even better. How could i accomplish this? Thanks in advance
Answer by clunk47 · Oct 26, 2013 at 06:35 PM
Try this Javascript example just to get started. Attach this to a cube or something, then in the text area, type something like
var console : String = "";
var input : String = "";
function OnGUI()
{
GUI.SetNextControlName("User");
console = GUI.TextArea(Rect(0, 0, Screen.width, Screen.height / 16), console);
GUI.FocusControl("User");
if(Event.current.keyCode == KeyCode.Return)
{
input = console;
console = "";
eval(input);
}
}
[1]:http://www.w3schools.com/jsref/jsref_eval.asp
Thanks for the help, but that is not the issue. $$anonymous$$y issue is how to allow the player to edit that so they can type in transform.Translate(Vector3.up);
Your answer
![](https://koobas.hobune.stream/wayback/20220613120656im_/https://answers.unity.com/themes/thub/images/avi.jpg)