Advertisement

Best way to add an interactive scripting language to a game

Started by November 19, 2017 07:04 PM
11 comments, last by Shaarigan 6 years, 9 months ago

I am thinking of making a game like screeps, where you use actual programming to control the game, but I'm not sure about the best way to do this.  I'm probably going to use lua or javascript for the language, and I would like to represent units in the game as objects that the user can command and modify, with restraints based on the actual game, like how screeps does it.  However, I am not sure how to get started.  I think I have to use C or C++ and then embed the languages, but I'm not sure where to go from there, for example, having objects in lua actually correspond to units in the game.  Are there any resources that explain how to do this?  Also, I'm not concerned about the graphics of the game whatsoever, it might as well just be a text adventure as far as I'm concerned, I just want the user to be able to control the game through scripting.

One thing you could do besides script-binding, is you could have a language that the user programs in, they submit their program, you check it for validity and then do some magic on it, and then - - send it to g++. 

Advertisement
18 minutes ago, h8CplusplusGuru said:

One thing you could do besides script-binding, is you could have a language that the user programs in, they submit their program, you check it for validity and then do some magic on it, and then - - send it to g++. 

Isn't that what embedding a script is?

1 minute ago, Vityou said:

Isn't that what embedding a script is?

No, it's executing a script ( lua ) vs running a binary ( say from c++ ).

1 minute ago, h8CplusplusGuru said:

No, it's executing a script ( lua ) vs running a binary ( say from c++ ).

Do you know of any resource that show how to do this?

1 minute ago, Vityou said:

Do you know of any resource that show how to do this?

which one

Advertisement
2 minutes ago, h8CplusplusGuru said:

which one

Either, whichever one is more popular or easier.  I just need a way for the game to be controlled in real time by the scripts.

a quick google has revealed, https://eliasdaler.wordpress.com/2013/10/11/lua_cpp_binder/

2 hours ago, h8CplusplusGuru said:

ok, so I understand how to add functions from C++ to a lua environment.  But what I'm looking for is how to add an object (a unit from the game) from C++ to a lua env for the user to access, and when the user does something with the object in the lua script, it is reflected in the actual game.

You could also offer some kind of node based scripting language like an AI Robot game on Android (which name I forgott :P ) did. You wrote "programs" for your robots to solve quests against an opposing team of robots in it.

This could be something very simplified in UI like this childs toy from the 90s

image006.jpg

This topic is closed to new replies.

Advertisement