Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
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 ...
congusbongus's user avatar
  • 14.8k
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 ...
Ryan1729's user avatar
  • 714
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 ...
Pikalek's user avatar
  • 12.4k
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 ...
Derrick Bouchard's user avatar
6 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 ...
DMGregory's user avatar
  • 135k
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"
Antoine Thiry's user avatar
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, ...
Sean Middleditch's user avatar
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 ...
Philipp's user avatar
  • 120k
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. ...
DMGregory's user avatar
  • 135k
4 votes
Accepted

How to properly split damage against armor?

If I've understood correctly, I'd do this as a two step process... Calculate how much the armor absorbs, then apply the rest to the player. Something like: ...
Basic's user avatar
  • 1,278
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 ...
Quentin's user avatar
  • 1,178
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 ...
Sean Middleditch's user avatar
3 votes
Accepted

Implementation details of Command Pattern in conjunction with Entity Component System

How do I populate the execute command if there isn't any logic that "belongs" to an entity? But there is a mechanism for applying logic to an entity: Systems. In ECS, Systems map behavior to ...
Mattia's user avatar
  • 398
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 ...
Mario's user avatar
  • 8,497
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: ...
M. Angler's user avatar
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 ...
DMGregory's user avatar
  • 135k
3 votes
Accepted

How to fix diagonal velocity being greater than axis-aligned?

Is there a fix for this so no matter what of the 8 I travel its the same speed? Yes... You want to apply a total force and split it between x and y To do this for any angle, you apply ...
Basic's user avatar
  • 1,278
3 votes

How to fix diagonal velocity being greater than axis-aligned?

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 <...
Kevin's user avatar
  • 6,150
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 ...
qubodup's user avatar
  • 124
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: ...
Stephane Hockenhull's user avatar
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 ...
House's user avatar
  • 73.2k
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 ...
Nils Ole Timm's user avatar
2 votes
Accepted

Can MoonSharp call functions from static classes?

One soulution could be creating a static callback function that in turn calls the function on the staic c# class so for exmple ...
Hampus's user avatar
  • 126
2 votes
Accepted

Should I create a Lua wrapper classes for my C++ classes, or should I bind them directly?

C++ aliases seem to provide a solution to your problem. Solution A The main benefit here is low maintenance. The other is you can avoid method call indirection overheads by avoiding wrappers (I ...
Engineer's user avatar
  • 29.6k
2 votes
Accepted

Roblox script: Can't get "IntValue"?

I think your misunderstanding is based around what val == not nil means. The expression not nil evaluates to ...
Anko's user avatar
  • 13.4k
2 votes
Accepted

Pressed key doesn't run out of special powerups

While the player holds down the space key, the else part of your code is never reached, so the deceleration is not applied. Basically, you'd have to execute this if ...
Christian's user avatar
  • 2,067
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: ...
sam hocevar's user avatar
  • 23.8k
2 votes
Accepted

Change transparency of image at runtime, LOVE2D

Just set the color to white-with-less-than-full alpha before drawing the image. For instance, this would draw your image at around 50% opacity: ...
Noah Witherspoon's user avatar

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