Creating scripting inside a game - how to

I have an idea for a game, wherein the player must control and repair the software systems of a spaceship or something similar, in order to

  • A) Fix the ship by ordering repairs
    or diverting power
  • B) Create “artificial intelligence”
    for the ship to maneuver by itself
  • C) Attack/defend the ship from some
    kind of enemy
  • D) Create security- or convenience
    systems on board.

The purpose is to create an engaging game, that may teach or engage players in learning how to code.

The programming language, I imagine to be identical or similar to C#, however it should not use any standard Unity functions, instead it should use a small library of functions only available inside the game world.

My problem is, however, I need to implement a programming language INSIDE the game. That is, you must be able to type code in a GUI element or something similar, have it compile and somehow affect the game world.

I’m not sure how to start. Are there any functions available to process code directly, or will I have to start from the bottom with this? Any insight would be useful, as would articles relating to this - Google Searches for “progamming inside a game” yields nothing useful.

I’d start by looking at Lua. It’s a pretty common modding language and it’s pretty easy to set up in Unity.

This may be obvious enough that you already though of it & it probably isn’t automated or efficient as much as you would like; but you could have the user enter a string & if it matches something then your script does something.

I am thinking also to a project similar where the player can write code inside the game, and just get an idea how. Can make smole function with variables, so is like you rewrite the C# functions that you want the player to use, and you may simlifi it so the will be more easy for player to use if he don’t know coding. sorry if my writing skill in english is not so good, hope you get it.

In my opinion, first you should do research about Regular Expressions. 1. It will make players to write your “code” in pattern that you want.

Second, OOP is your friend. Create some object named Command which got its name, required regexp, function that does something. Then you create your gameObjects that got their own Command objects.