C
C
Callin2021-01-11 08:54:46
Unity
Callin, 2021-01-11 08:54:46

How to implement compiler in game?

There is an idea to create a game where you will need to program your character. That is, you write code - and something changes for the character. Is it possible to implement this at all?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
d-stream, 2021-01-11
@Callin

https://docs.microsoft.com/en-us/troubleshoot/dotn...
https://docs.microsoft.com/en-us/dotnet/csharp/exp...

V
Vasily Bannikov, 2021-01-11
@vabka

Yes. Here people give an example with embedding a full-fledged compiler or interpreter (Compiling C # at runtime, lua / luajit) - this is possible, but in principle no one forbids embedding some kind of limited DSL and interpreting it yourself. You need to step back from the task.
Embedding a full-fledged language is a rather dangerous feature, as you can run into the publishing rules in the Apple appstore, which prohibit software that allows you to interpret custom code if the game is mobile.

D
Developer, 2021-01-11
@samodum

It's strange that the solution marked the wrong answer.
This approach is fundamentally wrong. Like the answer about Lua.
You need to look towards ANTLR. It allows you to implement independent processing and "compilation" of text in any language invented by the author.

F
freeExec, 2021-01-11
@freeExec

LUA

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question