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 different from the language in which the host is written, but any program-inside-a-program abstraction could be considered scripting.
Conceptually, the common ...
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 ...
A simple way to build a procedural generator is:
Randomly build things
Run a function that checks whether the output is good
If the output is not good, go to step 1
Even if it takes thousands of runs to complete, most simple generators get by just fine with this approach. The advantage is that there's not a lot of smarts required in the generator, and ...
You are ONLY generating Perlin noise. This is actually the same as using only one octave, at any frequency. You can base yourself to implent FBM (Fractional Brownian Motion), It is actually what all engines use to make Perlin noise more fractal looking.
Bringing it down to code, you can use it like this:
function fBm(float x, float y, float z,...
Quick note: I don't know lua, however I am fairly good at maths/physics and please bear with me if I cover ideas you are already familiar with.
For any object under the force of gravity the horizontal component of the velocity, vx, will remain constant throughout the motion.
In this picture the red dots are made at equal times, so the ball travels equal ...
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 ...
Lua is a pretty well developed scripting engine that is flexible and easy to integrate to your games, and is already supported in many game engines, for instance:
Agen (Lua; Windows)
Blitwizard (Lua; Windows, Linux, Mac)
Corona (Lua; Windows, Mac; iOS/Android)
EGSL (Pascal/Lua; Windows, Linux, Mac, Haiku)
Grail Adventure Game Engine (C++/Lua; Windows, ...
Do python games use Lua?
Is it a resonable thing or I should just stick to pure python?
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 it's ...
Given a restriction of "all areas are at are at least 3-4 blocks wide" the first idea that leaps to my mind is something like the following:
pick one of 3x3, 3x4, 4x3 or 4x4
place a block of that size in the center of the grid
pick a direction (up, left, right, down)
try to place a 3x3 block alongside previously placed blocks in that direction
You could use pre-generated polyominoes as meta shapes to build an assortment of buildings.
Let's say your minimum acceptable distance is 3 blocks.
Then the smallest acceptable building unit we'll consider is 3x3. For convenience, I'm going to call that a cell & it gives an area of 9 blocks.
Next, take your target starting area & divide it by the ...
The method I have used with good results is to give each class that needs Lua bindings a static class method with the following signature:
static luabind::scope luaBindings();
The definition of this method looks like this:
using namespace luabind;
Just replace the source files if you're compiling from source, or the DLL if you're using the precompiled one (preferred).
Per the Installation Guide:
LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua
into your application, you probably don't need to do anything to
switch to LuaJIT, except link with a different library:
LuaJIT is ...
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 ...
You really shouldn't use pixel coordinates for game logic.
Just use coordinates that are independent of screen size, and make rendering code account for different screen sizes, this way you get much more flexible and maintainable code.
So for example assume you are using 1 meter as one unit.
Your screen is 2 meters high and 1 meter wide(on every device).
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 want. Generally you build up an interface to allow some flexibility with the scripting language of your choice so you can use the scripting language in a series of ...
could block certain functions, but that wouldn't be nice for the modders
It's perfectly nice for modders and is basically what everyone does. The only ones you need to restrict are the IO functions, of course, since Lua doesn't really include anything else out of the box.
You can instead of "blocking" them replace them with your own versions that do extra ...
In math, the = sign represents the equality comparison operator, an assertion that "the thing on the left has the same value as the thing on the right."
This operator is commutative: you can exchange the left & right sides without changing anything (the statement that the left & right sides have the same value remains as true or as false as it was ...
This is a pretty general question with many different approaches. I'll just mention two major differences in coding AI logic into Lua.
As a prerequisite you will still need to expose C/C++ low level functions so that lua can make function calls to affect game systems or query for game information.
Movement, pathfinding, inventory, etc, etc
Script as low ...
I think that the problem here is not lua or xml but the design. IMO you should use a fatory pattern coupled with a prototype. Your lua script should be used to create a new prototype of monster, then your factory will create new "instances" of this monster (cloning the prototype). This way you have to run your script only once.
However, if all of your ...
LUA would work fine for programming an AI.
Here is a basic article over making a FSM in LUA
Here is a basic set of classes to make a desicion tree in LUA
LUA overall is an extremely powerful language. Any scripting language would ...
0) Move your constructor to a separate file, there's no rule that says your entire class has to be all in one physical .cpp file.
1) Put your binding code in a separate function in a different file, have the constructor call it? This would be the preferred method.
2) write your binding code in a separate file, inline, and #include it directly into your ...
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, but it remains completely relevant today.
This book will not only show you how scripting languages fits into native code, it also teaches you how to implement ...
I have compile the lua code in the AgentClass object, and in the AgentInstance code I call funcions passing this pointer like:
lua_getfield( L, LUA_GLOBALSINDEX, SCRIPT_AGENT_NAME );
lua_getfield( L, -1, "init");
lua_getfield( L, LUA_GLOBALSINDEX, "Agent" );
lua_pushstring( L, "__obj" );
lua_pushlightuserdata( L, (void*)this );
lua_rawset( L, -3 );
auto ret ...
I use KopiLua, which is a Lua interpreter rewritten entirely in plain C#.
KopiLua and LuaInterface can work together and in fact someone did, calling it KopiLuaInterface. Just google that.
Update: For those reading this answer, there have been two other projects that do the same which might be worth looking into as well: NLua and Moonsharp
Start from the top left and use a BFS flood fill to get all of the same color cells of the starting cell (while marking the cells as visited). Once the BFS finishes keep traversing your hexmap looking for unvisited cells. If you find an unvisited cell start another BFS flood fill (same idea as before). To determine if you have finished either keep a count of ...