Hot answers tagged lua
23
The only benefit I can currently think of is that you can make some coding updates, via Lua, without having to recompile.
Do not discount the utility of this so easily. You will never understand how productive you will be until you take away the recompilation step.
The "flow" is a fairly well-understood psychological concept when it comes to work. The ...
16
Would using Lua scripts to define game logic for an MMO server be a lot slower than compiled in C++?
TL;DR: Lua does have overhead, but if used properly it is negligible and easily mitigated. Don't use it for heavy math operations or transforming geometry. You will probably not see any performance problems at all using it to script a GUI.
I've done some basic benchmarks regarding Lua's performance as a game scripting language, and it's pretty damn fast. ...
14
If you're interested in developing games using Lua, I'd highly recommend checking out LÖVE which is a framework for making 2D games in Lua. Checkout their wiki for lot of resources to get you started. :)
12
As far as scripting languages go, Lua is very fast, but like anything it varies depending on the processor. For example, Lua would not be great on a console platform because it tends to be very branchy, and some console platforms branch very slowly. To best answer your question, I would suggest running some benchmarks. See how fast Lua performs some various ...
12
The iOS developer program agreement section 3.3.2 reads (in part) as follows:
An Application may not download or install executable code.
Interpreted code may only be used in an Application if all scripts,
code and interpreters are packaged in the Application and not
downloaded.
When the license agreement was updated in 2010, this change was ...
11
Sorry, no matter what kind of encryption on the client side you do, if you store sensitive stuff on the client, it will be hacked.
The client has to be able to read the data in the "encrypted" file. So you are giving the lock and the key to the client in a competitive game, and telling them not to edit anything inside your encrypted file.
Your client will ...
11
We have a similar situtation in our project, and we solved the problem by saving components (not functions) to LUA metatables. Basically, when we are creating an entity (or game object as we call them) on LUA side, code looks something like:
function createShip()
...
self.transform = registerToComponent("transform")
self.sprite = ...
9
Where I work:
Pros:
iteration time improvements. Our game is set up to poll a host filesystem for changes and automatically "slurp" in changes. (They only take effect at next file open, but in practice, that's a major improvement: reload the level, and your new lua changes come in immediately.)
console integration. Any debug functionality can be hooked ...
8
A socket based messaging scheme can be used to allow any arbitrary language to interact with the AI. You could use binary based messages, xml, text, etc. Just clearly define what the message format is and what messages you will send and receive.
This technique works relatively well for light to modest communication handling. There is a latency penalty ...
8
Since you are talking about screens, I feel it's best to separate all that logic into different Screens. What I normally do:
Define an interface called screen, and have multiple screens implement it. Like LoadingScreen, MainMenuScreen, GameScreen, GameOverScreen, HighScoreScreen etc.
In your game you put a variable that holds the current screen. Each loop, ...
7
You can precompile lua using the luac tool in the standard distribution:
luac myluafile.lua -o mycompiledluafile.luac
To obfusticate the file, use the -s option to remove all the debug info. This won't make you immune to decompiling, but why does that matter?
The -l option produces an annotated bytefile, which is really nice for learning how lua works ...
7
It seems to me that the easiest way to do this would be in two steps:
Determine the smallest possible convex polygon surrounding all red nodes.
Expand the convex polygon until it reaches the largest possible area without intersecting with white nodes.
Suppose we start with this situation:
Look at that glorious programmer art. I've chose red and green ...
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
This is were I would point you (http://www.xnua.com/xna_lua_xnua), but it hasn't been updated for a long time.
C# is great language, and could in a sense be used as a scripting language within your c# game. Nick Gravelyn has created some nice tutorials about tile engine (http://blog.nickgravelyn.com/downloads/#tileengine) and used a custom scripting engine ...
6
Disclaimer: I've created the two tutorials I'm going to link here
I've done two tutorials. None of them is complete, but will get you from 0 to 80% quickly.
The first one is a LÖVE-centric one called love-tile-tutorial:
https://github.com/kikito/love-tile-tutorial
It's about 50% done. Starts with the basics, and deals with Images & Quads, as well as ...
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
This will be hard to fix in so little time, especially since you're using such a peculiar structure, but well, let's give it a try. I'll post and edit as I notice the most glaring problems.
Step 1) Proper Camera Panning
The first thing that jumped out of your post like a madman was the part where you said:
So, instead of the character moving, ...
6
You'll probably get farther with Google with a bit of terminology: the usual jargon for a recalculation of an A* path is a "replan". In more specific direction, the situation you raise is the primary stated motivation of HPA*; it's a fairly well proven-out algorithm at this point and is likely to provide solid guidance.
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
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
Use composition to model properties of complex entities rather than inheritance. More specifically, use a component-based design rather than an inheritance-based design for your entities. Each component has a known metadata table and your entity's metadata table just exposes a list of components.
http://gameprogrammingpatterns.com/component.html
...
5
LÖVE isn't as a library that you import into Lua. What it does is embed the Lua interpreter and expose its game functionality to that interpreter.
If you'd like to interactive play with the API, there's a couple of libraries built for debugging and live coding:
https://love2d.org/forums/viewtopic.php?f=5&t=2473
https://github.com/vrld/love-console
...
5
Lua was actually designed to be an efficient data file format. It's original use was to load huge geographical data sets. Actual scripting/logic features came later. Even with all the new scripting features, it is still used by its original authors to store and load large data sets.
That is not to say that Lua is the most efficient choice. That will ...
5
A good approach is to design the behaviors in C++, and put the desicion parts in Lua scripts. The benefit is you can modify AI decisions without compiling your game; and with some good design, you may be able to modify AI desicions at runtime (opening up a debug window in game and change the variables to affect the decisions).
A behavior can be related to ...
5
I've been writing a few blog posts about this recently. Specifically for entities data files, and the just published post for taking those data files and turning them into entities.
Essentially, you write your own parser for a custom script language. The parser reads components into "blueprint" form for your factory. Each entity will have a set of component ...
4
I would pick protobufs. The temptation to do clever things with Lua would be too strong. First I would cave and write basic arithmetic because I can just eval it in Python. Next I would let myself use intermediate variables because they're easy to parse out. Eventually I'd need Lua-in-Python for any tools I wrote in Python, and then I'd want to go back in ...
4
To the best of my knowledge Relic's Essence Engine Series (as used in Company of Heroes and Dawn of War II) uses Lua or a dialect of it for unit stats and mission scripting. There are no real web sources for it, but you could always check out some of the mods at RelicNews.com to ask your way around if you are interested.
The Spark Engine by Unknown Worlds ...
4
tolua++ uses all the metatable features to allow a very straightforward manipulation of your c++ types in lua.
For example, this declaration :
// tolua_begin
class SomeCppClass
{
public:
SomeCppClass();
~SomeCppClass();
int some_field;
void some_method();
};
// tolua_end
Will automatically generate the lua bindings to allow this lua scipt :
...
4
It's not entirely clear what you're asking, but there's nothing inherently "wrong" with the way you are structuring your state machine. As long as it fits the task at hand, any implementation can be considered "correct".
One change I would suggest making is to allow the states themselves to be instanced, so that you can store state in your instance. This ...
4
Actually there are 3 great advantages:
Runtime loading which allows you to load scripts during the application's execution.
Sandboxing http://stackoverflow.com/questions/3400851/execution-time-limit-for-a-lua-script-called-from-the-c-api/3400896#3400896
Portability
These factors allow you as a game developer to enable features that will speedup the ...
Only top voted, non community-wiki answers of a minimum length are eligible