Hot answers tagged scripting
54
Scripts are usually compiled at run time, while the host language will be compiled at compile time. This means that we don't need to recompile if the script changes. Recompiling a full game can take minutes to hours, which implies a big productivity hit.
Usually, the critical code or backend code will not be scripted. This code should run fast and often ...
28
You asked the wrong question. The real question, I think, is why do we put up with "non-scripting" languages like C, C++, Java, and so on? And the answer is one reason: performance. (And maybe inertia, but that inertia is there because of performance, and anyone who can write good C/C++/Java can write at least passable Ruby/Python/Lua/JavaScript.)
We use ...
28
Unity is growing in popularity in the industry, mostly in smaller companies. However, it is an excellent teaching environment. It is an important teaching tool, but not particularly common among mainstream companies. It's okay that you don't prefer it.
Let me note something here, though, as I often see a confusion among programming students. "C++ ...
21
Unity is a perfectly valid solution in this context. Imagine for a second having 12 people, most of whom are still in the process of learning C++, writing a large and complex game application using it. In the amount of time spent debugging alone you will probably have been able to write another game in Unity.
I'm not saying knowing how to use C++ is not ...
16
First of all, you should decide what part of your game is scripted. One option is to have a fully scripted game in the sense that while the time-critical backend operations are coded in C++, all the game logic is in the scripting language. Designers use the backend as a library called from the high level scripting language. On the other extreme, you can have ...
15
I advocate not using a scripting language in C#. C# is already solves the vast majority of problems that a scripting engine is used to solve. Just use C# in the way you would use a scripting language.
Because I've been over this several times before, here is some reading material for you:
A scripting language for XNA (duplicate of your question, but on ...
13
Scripts are written for a scripting language. People can use the words in slang sentences to get the muddling that you are referring to but ask anyone for the definitions of Script, Scripting and Scripting Language and you will get something like: Scripting is the act of writing Scripts using a Scripting Language.
When you embed a scripting language into a ...
12
Dialogue could be provided in any form/structure you wish it depends on how you parse the information that makes the difference. I will provide you with a basic XML syntax to get you started without understanding your games structure or language I afraid i cant provide an implementation.
<?xml version="1.0" encoding="UTF-8"?>
<npcs>
...
11
The term you want to search for here is "coroutines" (and usually the language keyword or function name is yield).
Coroutines are program components that generalize subroutines to allow multiple entry points for suspending and resuming execution at certain locations.
The implementation will depend first of all on your language. For a game you want the ...
9
As far as simple, "one-liner" scripts are concerned, Lua is a perfectly legitimate choice. Function binding is easy, even with the native API (though there are plenty of helpers for this). It's syntax is pretty easy to learn. Oh, and the runtime is tiny, if that sort of thing matters to you. You won't even have to include its standard libraries, so it'll be ...
9
Using scripting has many advantages over "core language". Some of these include:
Moving (more) of the content from core developers to artists, freeing the core developers to engine tasks from gameplay tasks
Scripts tend to be sandboxed, can't do anything really dangerous in it
Modifying scripts does not require recompilation and re-execution of the game
9
I can't compare the two, as I've only had experience embedding IronPython in a C# game so far. Here's what I like about it though:
1) It's easy! Download the IronPython DLLs, add reference in project,
using IronPython.Hosting;
var engine = Python.CreateEngine();
var product = engine.Execute<System.Numerics.BigInteger>(@"
print ' ...
9
My game uses an entity component framework and uses scripts to define entities (this doesn't directly define behavior, I'll talk more about that at the end). The scripts define the actual components to be used for creating each entity. It uses a simple scripting language I created. Here is a simplified version of one of my scripts:
ENTITY:"Goblin"
{
...
8
Lua-scripted video games
Lua-scriptable game engines
I think Lua is the best shot.
This article is about integrating Lua and C++. It says:
LuaBind is great product but for me it looked too complicated. For one the code is not easy to follow where the classes and objects are. Also seeing that I wanted to integrate Lua into a wxWidgets application, using ...
8
Are there a lot of companies using it because they can't afford to use something else?
Yes, but "afford" is so much more than just straight up dollar values.
Yes, the feature set that Unity Pro gives you at the cost they charge is ridiculous, especially considering the fact that it's seat licenses instead of per-title licenses.
But on top of that, ...
8
Unity is using Mono behind the scenes. Every time you make a change to your C#/UnityScript scripts it recompiles the code almost instantly.
If you look in the data directory of a standalone unity player, you can see it has compiled all the scripts into Assembly-CSharp.dll, or similar.
So yes, the C# is being compiled.
7
Both, in general. Your scripts should talk to an abstracted -- or at least intermediate -- layer of functionality and not the engine itself.
First, this provides you an extra measure of control and security. It allows you to easily, cleanly define the interface a script is allowed to have with your game and thus what it can muck about with, as well as ...
6
My advice would be "don't".
I've used a domain-specific markup language for game data. It was a pain. I spent days designing it, and then every week or two I needed to tweak it to add more features. At one point I realized I needed to automatically generate some of my game data, and I ended up writing a small program to parse input files in the markup ...
6
Various scripting languages, both text-based (ones with simple syntax - LUA for example - can be more accessible for a non-programmer), and graphical (Unreal, for example, is very GUI oriented).
Alternatively I've seen people just expose tweakable stuff through an editable text file (sometimes a CSV formatted file usable in Excel), if you expose the right ...
6
I'd recommend taking a look at LÖVE "an awesome framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X and Linux." It's clearly not an alternative to the Cryengine, but should certainly demonstrate how to effectively utilize the potential of Lua for entity creation and game logic. Combine that knowledge with how ...
6
The core issue, from what I can see, is not C++ or Unity3D, but rather do you need a high-level solution or a low-level solution.
A low-level solution is one which you get dirty with the processes of handing input, managing memory or loading the models. A high-level solution is which you get one neat package, like Unity3D.
To me, whether to use Unity3D (or ...
6
Quite possible.
You could probably use the GNU Interpreter for Java or some other such system. However I think you'll find a lot more cases (as mentioned above) of people using Lua, Python or other languages in games. Lua in particular is very well suited for the task of embedded scripting.
Additionally, you might check the jog interpreter project, ...
6
Scripting is generally used in bigger projects to allow non-programmers to easily add content to the game. This can be new quests, interfaces, gameplay for levels, etc.
A scripting language in itself shouldn't be difficult for a programmer to learn, what will take time is the integration into your game framework.
Whether it's worth it or not is really your ...
6
I would definitely store the position of entities in the map file. I mean, if you have multiple copies of the entity in your scene then you'd need multiple scripts that are identical except for the position; horrible! I consider that way more important than either of the points you mentioned.
6
I'm fairly sure Lua can do everything you need relatively simply. I use Lua and C++ in my game. I looked at various wrappers like LuaBind, or using a generator like Swig, but I decided I didn't want any of that stuff and I wrote my own wrapper which I ended up making open source in case other people found it useful.
Using my little library you can do stuff ...
6
I've figured out how to do this. As I expected, since IronPython compiles down to CLR, C# and IronPython objects can interact with each other just fine with no special treatment necessary. I've created a script which actually creates a new type of Component which can be referenced just fine from C#.
A brief word on my game's structure: Its solution has two ...
6
1) Would one embed the script itself in the entity object before persisting to it to the disk? Is this okay?
You'll get cleaner diffs in your version control and encourage reusable scripts by providing the actual script out-of-line and having the entity merely store, say, a filename and script parameters. Storing the script in the entity itself is ...
6
Do python games use Lua?
Generally? No.
Is it a resonable thing or I should just stick to pure python?
Define "reasonable"?
Python has been used in many game development scenarios. While Lua may be well known among some game mod circles (like WoW GUIs, Garry's Mod, and so forth), Python was the language of choice for Civilization IV modding. So ...
5
Each new lua class is two lines. Each new C++ class is pain.
No whining about types when all you want is shuffle values around.
Garbage collection.
Script code is nicely isolated in virtual machines, away from all those nasty wandering segfaults and array overflows.
5
Scripting languages for game logic is a very good example of the software architecture pattern Alternate Hard and Soft Layers. There's a good discussion on that site (and others I'm sure) on the benefits of doing so.
Only top voted, non community-wiki answers of a minimum length are eligible
