Hot answers tagged

16 votes

Procedurally generating a building of specific area

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 ...
  • 14.6k
9 votes
Accepted

Calculating Linear force required to hit a specific vertex on a parabola

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 ...
  • 481
7 votes

Procedurally generating a building of specific area

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 ...
  • 694
7 votes
Accepted

Procedurally generating a building of specific area

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 ...
  • 9,334
6 votes
Accepted

How do I get the player's position in Roblox Studio?

I feel your pain. Roblox is very confusing, despite their claims that it is an easy way to learn scripting. To get a player's position (server side) you need to access the player's character ...
5 votes
Accepted

Love2D game and editor in two separate programs

Alright, found it ! I had to add this to the main.lua file in the editor folder and it worked : package.path = package.path .. ";../?.lua" require "core.engine"
5 votes
Accepted

var=time() vs time()=var pico8/lua

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 ...
  • 117k
4 votes
Accepted

C++ - Lua Preventing malicious lua code

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, ...
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 ...
  • 113k
4 votes

How can I correct an unwanted fisheye effect when drawing a scene with raycasting?

It looks like you're firing out your rays at evenly spaced angular intervals. ...
  • 117k
3 votes
Accepted

LOVE Physics - Breaking Joint Chains (LUA / Box2D)

Directly editing the position of a box2d body will produce non-physical behaviour, it's present because sometimes you will need to teleport bodies to a far away location, or reset the position of an ...
  • 1,695
3 votes

Lua Implementation

This is not exactly an answer - rather a suggestion. A lot of game developers are shifting from LUA (it is slow and it forces you to push data back and forth). For example Star Citizen is using ...
3 votes

Performance Issues Using Lua in C++

I think part of the problem (which also caused me to misinterpret the question at first) is the lual_dofile() calls. This sounds like all scripts are always loaded ...
  • 8,292
3 votes
Accepted

What functions should be called in C++ gameloop from Lua Script

I would generally recommend to avoid making high volume calls into Lua. That is partly about performance but mostly about engine architecture. To get the perf bit out of the way: the bridging code ...
3 votes
Accepted

Const returning C++ method can't be bound with LuaBridge

Sounds like a bug in LuaBridge, so you should report it. As for fixing your project, just remove the const, it doesn't make sense anyway since you're returning a ...
  • 1,148
3 votes

Create a game start-up menu screen with Lua/love 2d

There isn't a built-in menu system for love2d. The developers take a 'do-it-yourself' approach to a lot of such things. Here's an example of how I ended up rigging my menu for my first time: ...
3 votes

Any advantage of having chunks with sizes by the power of two?

The main advantage of power-of-two sizes is that division by a power of 2 (on an integer) is just a bit shift, and modding is just a mask. Both of these operations are blazingly fast to do on gobs of ...
  • 117k
3 votes

2d diagonally velocity greater than straight-line velocity. How to fix?

You use trigonometry. Here we can just use the Pythagorean theorem: a² + b² = c² If the player is moving at a 45° angle, a and <...
  • 3,753
2 votes

How do I change a LÖVE2D game executable's icon?

The steps below are also covered in a video tutorial (icon topic starts at 2:22). Create an .ico file using GIMP, you can use the game.ico or ...
  • 124
2 votes
Accepted

NLua - How to implement Roblox like function security?

The best way to create a safe environment to Lua, is creating a sandbox using lua. You just need to "hide" the unsafe functions the let only the "safe" functions visible. For exemple: os.exit = ...
2 votes
Accepted

Garry's Mod HatsChat2 chat colors permissions messed up?

If you still haven't the answer, change your color table to this: ...
2 votes

Switching a project written in Lua to a compiled language

C++ should be very efficient, but it also would make me have to worry about low-level details like manual memory management, and compiling for different platforms. Modern C++ highly discourages ...
2 votes
Accepted

In ROBLOX, how can I check what is in front of me?

Just like to say that I have little experience in the lua language BUT, If you take the x y z position of your model "Freddy" and the x y z position of all your other bricks, from there you could ...
  • 102
2 votes

How can i run my .LÖVE game directly from the lua interpreter?

Here's what I did that works for quick running. I created a main.lua file which has only one line require('main2') I put that file in a zip by itself, gave it ...
  • 21
2 votes
Accepted

HardonCollider Error: attempt to call method 'addRectangle' (a nil value)

Answering my own question here, in case somebody else encounters this issue. Looks like i have been reading outdated documentation & samples, according to the new docs there is no such method as <...
  • 131
2 votes
Accepted

Logical math behind jumping in a 3D world

It's the same as you'd do it for 2D, just with an extra axis. Use the same exact equations you do for a 2D game, something similar to the equations of motion or the kinematics equations. For each ...
  • 72.8k
2 votes
Accepted

Dynamic force behind logical jumping on 3 axis'

So first, in the formula: velocity.x = x - ( x + ( 10 * math.cos ( ( rz + 90 ) * math.pi / 180 ) ) ); The two 'x's cancel out each other: ...
2 votes

My perlin noise height map doesn't have smooth transitions and goes directly from black to white

There is a bug in the final normalisation code, fortunately it’s easy to fix. You only need to change: map2[x][y] = map2[x][y] * mapMultiplier into: ...
  • 23.5k
2 votes

Got unexpected results from perlin noise. Wondering what it is doing?

You are going outside the 0..255 range. That's why you see these color bands, since you are goint the whole range of values between 0..255 for every integer. You are multiplying by 255 twice. This ...

Only top scored, non community-wiki answers of a minimum length are eligible