97
votes
Accepted
How does Lua work as a scripting language in games?
Scripting is a programming abstraction in which you (conceptually) have a program (the script) running inside another program (the host). In most cases, the language in which you write the script is ...
42
votes
Accepted
What's the technology that allows programming inside a game?
Scripts written in scripting / embedded / interpreted languages such as "Lua", "Lisp" or "AngelScript" (more here) can be updated during the game [*] and then are interpreted (= executed) on the fly.
...
12
votes
Accepted
What can I do to avoid one-off flags and checks throughout my code?
Have you looked into entity component systems and event messaging strategies?
Status effects should be components of some sort which can apply their persistent effects in an OnCreate() method, expire ...
12
votes
What's the technology that allows programming inside a game?
Embedded language is the proper technical term. In practice, languages which are used inside other applications (such as games) are often referred to as scripting or even interpreted languages, ...
11
votes
What can I do to avoid one-off flags and checks throughout my code?
RobStone is on the right track, but I wanted to elaborate since this is exactly what I did when I wrote Dungeon Ho!, a Roguelike that had a very complex effects system for weapons and spells.
Each ...
11
votes
What's the technology that allows programming inside a game?
You are looking for a way to change the code into some actions. This is precisely what interpreters are doing.
Take a look at Python. You run it, and bam! You land in REPL(Read Eval Print Loop).
You ...
7
votes
Accepted
Is it possible to mod a game to use a scripting language like Lua?
It depends on what kind of modding the game allows.
When the game in question already includes a sufficiently powerful script interpreter, one could write a transcompiler which takes a script written ...
6
votes
Accepted
How do engines that can be scripted with a different language than the engine code work?
There are many ways to implementing scripting in game engines, or applications in general.
Most conventional scripting languages are just like any other library. Just as libpng interprets a ...
5
votes
Accepted
NPC daily routines and scene loading
Don't hard-code it, or it'll indeed end up very messy.
You need to script the NPCs daily routines into some data file (XML or other).
Something along the lines of:
...
5
votes
How does Lua work as a scripting language in games?
Scripting languages like Lua can be used in several ways. As you said you can use Lua to call functions in the main program but you can also just have Lua functions called from the C++ side if you ...
5
votes
How to send an interface message?
Method 1 - Unity UI Event System
Thanks to Byte56 for pointing out that there's a new approach to messaging in Unity, which is much more similar to what the asker describes in Unreal.
One quick ...
5
votes
Accepted
What is the class name in Unity's AddComponent?
It's the class name of the component you want to add. For example, if you created a MonoBehaviour script named GoToPosition and wanted to add it to a game object ...
5
votes
In GameMaker, is it possible for users to code something into a game while playing, and verify that it is correct?
What you're describing is effectively running gameplay mechanics in a virtual machine, which can simplify the process of authoring them and insulate against bad behaviour.
As it happens, a lot of ...
5
votes
Accepted
Array but with a name for every element (value)
There are multiple methods to deal with this.
1) You could create an enum with custom values that you could refer to:
...
4
votes
How does Lua work as a scripting language in games?
Since no one mentioned this, I will add it here for those interested. There is a whole book on the subject called Game Scripting Mastery. This is a fantastic text that was written quite a while ago, ...
4
votes
Is it safe StringToHash() to use in Unity?
Assuming that the hash function used by StringToHash doesn't have serious bias, the chance of two hashes being alike is one in 4 billion. When you generate a lot of hashes, the chance of a collision ...
4
votes
Accepted
Can you write the current frame number to a text file?
You can retrieve the number of frames that have passed with Time.frameCount();, if that's what you're looking for.
http://docs.unity3d.com/ScriptReference/Time-...
4
votes
Accepted
Unity3D: 'Physics' does not contain a definition for 'Raycast'
I'd guess you made your own class or imported some other class named Physics. Try fully qualifying it UnityEngine.Physics.Raycast...
4
votes
How to make Unity game moddable with scripting in a friendly way?
A somewhat blunt approach would be to let modders write C# code and then have your game read & compile those scripts, using them as though they were code the game was built with.
This has some ...
4
votes
Accepted
Event Trigger for sprite not working
I see that the backward image is turned around 180 degrees to make it face opposite the direction of the forward image. This means that its front side is facing away from the camera. By default, this ...
4
votes
Is allowing the server to remotely execute code on a client a security risk?
You might want to ask yourself if you really need client-sided scripting at all. You might be able to make many interesting mods possible by simply making your network protocol powerful enough. Most ...
4
votes
An object reference is required to access non-static member
Your nextLevelName member variable is not static, meaning there could be a different name set on each instance of the ...
3
votes
How does Lua work as a scripting language in games?
Most scripting languages, including Lua, operate on a Virtual Machine (VM), which is basically a system to map a script instruction to a "real" CPU instruction or function call. The Lua VM normally ...
3
votes
Player in Spaceship
Each rigid body has an attribute indicating if it's affected by gravity or not. You can just mark that attribute as true, whenever player enters the spaceship, and later turn it false, when he exits. ...
3
votes
"Binding" script functions to C++ functions
There is no one way to bind an engine with a scripting language, nor is there really an easy way or a best way, it's all very dependent on your architecture, scope and ambitions, I can think of two ...
3
votes
iOS build size is too large in Unity
There is a unity guide for general optimisation on the unity website.
To summarize it quickly (read the article):
Reduce texture sizes (You can have specific settings Just for IOS)
Compress meshes ...
3
votes
Accepted
How can I get the assignment of an object back?
You are creating a tower prefab with Instantiate (towerPrefab, transform.position, Quaternion.identity);, but you don't do anything with the GameObject it returns. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
scripting × 261unity × 105
c# × 88
c++ × 30
lua × 25
python × 14
entity-system × 11
modding × 11
java × 9
architecture × 9
xna × 8
animation × 8
unityscript × 8
software-engineering × 7
javascript × 6
ai × 6
vector × 6
component-based × 6
udk × 6
2d × 5
camera × 5
physics × 4
3d × 4
movement × 4
multiplayer × 4