in-game programming console(how to?)

hello guys.

I wanted to ask if you can point me in the right direction or help me in the making of an ingame programming console. i’ll be more specific:

i’m working on a project for my university to teach programming in an interactive way so i came up with the idea of making a game where you could program your character, it will basically be a 2D side scroller game where there’s a little guy walking and solving puzzles or doing some stuff, the game will offer a variety of levels where each level is about a programming subject(ie. variables, control flow, loops, etc) and each level will have a console where the user can insert some instructions and it will be parsed and if they are correct then the character will be programmed to do whatever the user said to.

for example in the level of variables it would be something like

Objective : make your character remember your name…

then the user would type in the console var name = ‘myname’ and click run and the character would say the name in the variable…

in control flow would be like

Objective: there are obstacles in the lvl , if you encounter them make your player run away

so the user would tipe

else if(obstacleIsVeryHigh)


this is something like the thing i want to achieve, it’s from
alt text

Well, what you need is some kind of programming language to use in the console, and some kind of parser & compiler to convert the script to actual instructions. For this kind of simple console language, designing your own language and writing a compiler for it shouldn’t be a huge undertaking, but you may be better off finding a pre-made scripting implementation of something like Lua, and using that.