- Home /
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
if(obstacleIsHigh)
jump;
else if(obstacleIsVeryHigh)
runAway;
. . .
this is something like the thing i want to achieve, it's from codecademy.com
Javascript has an "eval" method, but other than that this is a duplicate question, just do a google search :)
i've been searching a lot but i cannot seem to find anything, could you link me to the duplicate?
@Dylan_velez
http://answers.unity3d.com/questions/7885/interpret-unityscript-at-runtime.html
Thats the only one I could find within 5 $$anonymous$$utes, however I remember there being a question that asked the exact same thing before... I just can't find it ;)
Answer by Hoeloe · Oct 18, 2013 at 06:17 AM
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.
You can actually compile JScript and C# at runtime using the CodeDomProvider
from .NET
Unfortunately the compiler used is not included when you build so some workarounds are required
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Scene saving 3 Answers
How to prevent MoveToward from reducing the speed? 0 Answers
CS8025 error 1 Answer