FakeBlocks.lua (Successor to NSMBWalls.lua)

Share and discuss custom LunaLua code and content packs for SMBX2.
Sambo
Snifit
Snifit
Posts: 208
Joined: Fri Jan 24, 2014 6:43 pm

FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Sambo » Mon Mar 14, 2022 9:52 pm

FakeBlocks

Hello, friends! You probably remember that old library I made a few years ago for fake walls that was called NSMBWalls. A lot has changed in SMBX since then, and it's time that code got an upgrade. Introducing FakeBlocks! This library looks better than the original, and it's easier to use, too.

In case you are not familiar with NSMBWalls, what this library does is, it adds the fake block effect from NSMBWii.

Demo:
https://imgur.com/6DQp45f

Features:
  • Looks more like the effect in New Super Mario Bros. Wii, complete with soft edges and a block silhouette effect.
  • Has an improved system for placing blocks, with proper support for moving or hidden layers.
  • Works with SMBX2's caustics effect, unlike the original.
  • Configurable!
  • Works properly with any number of players.
  • Easy to set up in any old levels that use NSMBWalls.
Using the Library:
Spoiler: show
First, download the block pack (link at bottom of post), then extract the contents to your level or episode folder.

The block pack includes these blocks:

Image
This is the Fake Block. This can be placed in the level, and will take on the appearance of a block with the ID provided in the Mimicked ID field in the properties box. However, it is recommended that you use Fake Block Capturers and Fake Block Spawners instead. They allow you to automatically place many Fake Blocks at a time.

Image
Here, the three other blocks are shown. This library uses a system that includes a capture zone and a spawn zone. The block with the green arrow (pointing downward) goes in the top left corner of the capture zone, and the one with the red arrow (pointing upward) goes in the bottom right. The block with the yellow icon goes in the top left corner of the spawn zone. When the level loads, all blocks within the capture zone will be converted into Fake Blocks and moved into the spawn zone. The layer that the blocks were placed on will be preserved through the transformation.

This may seem more complex than the original, but I have found it easier than placing the blocks on a separate layer, directly above the objects they are supposed to cover up, which is what you had to do in the original. It also makes it so the fake blocks can easily be placed on a moving layer. I didn't use a sizable block, because I find placing all the blocks on top of a sizable to be a pain.

Image

You can use multiple sets of these blocks in the same level. Each one of these blocks has an ID that can be configured in the properties box. Blocks with the same ID are in the same set. Each set should contain one spawner and two capturer blocks. If a set is incomplete or has too many blocks placed in it, the tester will show a warning message. The in-game result of these block placements is shown below.
Image
Configuration Options:
Spoiler: show
To configure this library, you must first load it in you level or episode's luna.lua file:

Code: Select all

local fakeblocks = require("blocks/ai/fakeblocks")
The configuration options for the library are shown below and explained in the comments, set to their default values.

Code: Select all

-- If true, semitransparent silhouettes of every block in the revealed area will be drawn
fakeblocks.showBlockSilhouettes = true

-- The color of the block silhouettes. Has no effect if the previous option is set to false
-- Can be a hex value like the one below or a Color object
fakeblocks.silhouetteColor = 0x2050a0

-- The maximum radius of the revealed area, in pixels
fakeblocks.revealRadius = 160

-- The rate at which the size of the revealed area changes while entering/exiting an area hidden by fake blocks
fakeblocks.revealRate = 6

-- The size, in pixels, of the soft edge of the revealed area. Set to 0 for a hard edge
fakeblocks.revealSoftness = 16
NSMBWalls Compatibility:
Spoiler: show
If you want replace NSMBWalls with this library in an old level, it's pretty easy.

First, remove any code that loads or configures NSMBWalls from your level or episode code. If your old code added any layers to the nsmbwalls.layers table, make note of them.

Then, you'll want to load fakeblocks.lua and configure it as shown below:

Code: Select all

local fakeblocks = require("blocks/ai/fakeblocks")

-- If true, blocks on the "nsmbwalls" layer will be converted into fake blocks
fakeblocks.useNSMBWallsLayer = true

-- List of additional NSMBWalls layer names. All blocks on these layers will be converted into fake blocks
-- Include any layers that you previously added to the nsmbwalls.layers table here, if any
-- Has no effect if fakeblocks.useNSMBWallsLayer is not set
fakeblocks.additionalNSMBWallsLayers = {}
Fixes for Common Issues:
Spoiler: show
You get an error in blockutils (like the one below)
Spoiler: show
Image
This means that your level contains a block that doesn't have an ingame image. This usually doesn't matter that much, but FakeBlocks.lua uses the block mask (but does not modify it, to be clear), which does not like blocks without ingame images. To fix this, find any blocks in your level that don't have ingame images, and create block-*.png images for them. These images just need to be 1x1 transparent images. The blocks added for FakeBlocks.lua itself do not need these images, as they have special handling for this case.
Download

Note that this library will not work properly in sections that have darkness with shadow casting enabled. This would require altering the block mask drawing code. However, it should work just fine if you use darkness without shadow casting. If any new features are added to smbx2 in the future that use the block mask, this library probably won't be compatible with them, either.

Let me know if you encounter any issues or have any questions!
Last edited by Sambo on Sat Mar 19, 2022 11:01 pm, edited 1 time in total.

Chilly14
Snifit
Snifit
Posts: 233
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Chilly14 » Mon Mar 14, 2022 10:10 pm

Wow, this looks great! Definitely gonna use this.

SpoonyBardOL
Swooper
Swooper
Posts: 51
Joined: Thu Aug 04, 2016 5:56 pm

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby SpoonyBardOL » Tue Mar 15, 2022 6:08 am

Nice, I was using a tweaked version of NSMBwalls but I'll be upgrading to this.

Sambo
Snifit
Snifit
Posts: 208
Joined: Fri Jan 24, 2014 6:43 pm

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Sambo » Wed Mar 16, 2022 5:30 pm

If anyone is having issues with NSMBWalls compatibility, try redownloading. There was a typo in the code that has been patched.

ShadowLabrys101
Bit
Bit
Posts: 73
Joined: Thu Jan 09, 2014 3:14 pm

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby ShadowLabrys101 » Wed Mar 16, 2022 7:02 pm

Now that looks more convenient than the older method!

Mal8rk
Blooper
Blooper
Posts: 199
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Mal8rk » Wed Mar 16, 2022 9:16 pm

this looks amazing! But I'm too lazy to update my episode just to include this lol

Soronexle
Bit
Bit
Posts: 67
Joined: Sun Jan 29, 2017 10:34 pm
Contact:

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Soronexle » Wed Apr 06, 2022 11:51 pm

Now this is a convenient upgrade and it definitely makes things easier once I figured it out. There is one thing that I noticed. I don't know if this is just me, but I noticed that slopes do not transform into fake walls cleanly. They look as they would when you use a block mask sprite to mask a slope. In other words, there's a black triangle that appears on slopes being captured as fake walls. Otherwise, it works well.

Sambo
Snifit
Snifit
Posts: 208
Joined: Fri Jan 24, 2014 6:43 pm

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Sambo » Sat Apr 09, 2022 4:36 pm

I tested this with slopes, and I didn't have any issues. Do you have a screenshot of it?

LooKiCH
Tweeter
Tweeter
Posts: 158
Joined: Tue Jun 13, 2017 11:28 am
Pronouns: he/him
Contact:

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby LooKiCH » Wed Apr 20, 2022 4:49 am

i found an error in the script, and it is related to block-751.ini, where "extra-settings" there is a file path error, you need to add "blocks/" to the file path
Image

Sambo
Snifit
Snifit
Posts: 208
Joined: Fri Jan 24, 2014 6:43 pm

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Sambo » Thu Apr 21, 2022 5:26 pm

Patched.

Ibaka
Monty Mole
Monty Mole
Posts: 146
Joined: Wed Apr 20, 2022 8:27 am
Flair: Nothing
Pronouns: he/him

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Ibaka » Tue May 31, 2022 12:32 pm

Sambo wrote:
Mon Mar 14, 2022 9:52 pm
FakeBlocks

Hello, friends! You probably remember that old library I made a few years ago for fake walls that was called NSMBWalls. A lot has changed in SMBX since then, and it's time that code got an upgrade. Introducing FakeBlocks! This library looks better than the original, and it's easier to use, too.

In case you are not familiar with NSMBWalls, what this library does is, it adds the fake block effect from NSMBWii.

Demo:
https://imgur.com/6DQp45f

Features:
  • Looks more like the effect in New Super Mario Bros. Wii, complete with soft edges and a block silhouette effect.
  • Has an improved system for placing blocks, with proper support for moving or hidden layers.
  • Works with SMBX2's caustics effect, unlike the original.
  • Configurable!
  • Works properly with any number of players.
  • Easy to set up in any old levels that use NSMBWalls.
Using the Library:
Spoiler: show
First, download the block pack (link at bottom of post), then extract the contents to your level or episode folder.

The block pack includes these blocks:

Image
This is the Fake Block. This can be placed in the level, and will take on the appearance of a block with the ID provided in the Mimicked ID field in the properties box. However, it is recommended that you use Fake Block Capturers and Fake Block Spawners instead. They allow you to automatically place many Fake Blocks at a time.

Image
Here, the three other blocks are shown. This library uses a system that includes a capture zone and a spawn zone. The block with the green arrow (pointing downward) goes in the top left corner of the capture zone, and the one with the red arrow (pointing upward) goes in the bottom right. The block with the yellow icon goes in the top left corner of the spawn zone. When the level loads, all blocks within the capture zone will be converted into Fake Blocks and moved into the spawn zone. The layer that the blocks were placed on will be preserved through the transformation.

This may seem more complex than the original, but I have found it easier than placing the blocks on a separate layer, directly above the objects they are supposed to cover up, which is what you had to do in the original. It also makes it so the fake blocks can easily be placed on a moving layer. I didn't use a sizable block, because I find placing all the blocks on top of a sizable to be a pain.

Image

You can use multiple sets of these blocks in the same level. Each one of these blocks has an ID that can be configured in the properties box. Blocks with the same ID are in the same set. Each set should contain one spawner and two capturer blocks. If a set is incomplete or has too many blocks placed in it, the tester will show a warning message. The in-game result of these block placements is shown below.
Image
Configuration Options:
Spoiler: show
To configure this library, you must first load it in you level or episode's luna.lua file:

Code: Select all

local fakeblocks = require("blocks/ai/fakeblocks")
The configuration options for the library are shown below and explained in the comments, set to their default values.

Code: Select all

-- If true, semitransparent silhouettes of every block in the revealed area will be drawn
fakeblocks.showBlockSilhouettes = true

-- The color of the block silhouettes. Has no effect if the previous option is set to false
-- Can be a hex value like the one below or a Color object
fakeblocks.silhouetteColor = 0x2050a0

-- The maximum radius of the revealed area, in pixels
fakeblocks.revealRadius = 160

-- The rate at which the size of the revealed area changes while entering/exiting an area hidden by fake blocks
fakeblocks.revealRate = 6

-- The size, in pixels, of the soft edge of the revealed area. Set to 0 for a hard edge
fakeblocks.revealSoftness = 16
NSMBWalls Compatibility:
Spoiler: show
If you want replace NSMBWalls with this library in an old level, it's pretty easy.

First, remove any code that loads or configures NSMBWalls from your level or episode code. If your old code added any layers to the nsmbwalls.layers table, make note of them.

Then, you'll want to load fakeblocks.lua and configure it as shown below:

Code: Select all

local fakeblocks = require("blocks/ai/fakeblocks")

-- If true, blocks on the "nsmbwalls" layer will be converted into fake blocks
fakeblocks.useNSMBWallsLayer = true

-- List of additional NSMBWalls layer names. All blocks on these layers will be converted into fake blocks
-- Include any layers that you previously added to the nsmbwalls.layers table here, if any
-- Has no effect if fakeblocks.useNSMBWallsLayer is not set
fakeblocks.additionalNSMBWallsLayers = {}
Fixes for Common Issues:
Spoiler: show
You get an error in blockutils (like the one below)
Spoiler: show
Image
This means that your level contains a block that doesn't have an ingame image. This usually doesn't matter that much, but FakeBlocks.lua uses the block mask (but does not modify it, to be clear), which does not like blocks without ingame images. To fix this, find any blocks in your level that don't have ingame images, and create block-*.png images for them. These images just need to be 1x1 transparent images. The blocks added for FakeBlocks.lua itself do not need these images, as they have special handling for this case.
Download

Note that this library will not work properly in sections that have darkness with shadow casting enabled. This would require altering the block mask drawing code. However, it should work just fine if you use darkness without shadow casting. If any new features are added to smbx2 in the future that use the block mask, this library probably won't be compatible with them, either.

Let me know if you encounter any issues or have any questions!
I dont see anywhere that i can mimick the ID of an object in the properties box.

MarioChallengerX2
Bit
Bit
Posts: 77
Joined: Sat Dec 31, 2022 4:34 pm
Pronouns: he/him

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby MarioChallengerX2 » Sun Jan 22, 2023 8:27 pm

Hey, so I like this lua code but I have one problem.
A rooms.lua problem.

Note: It works fine but the problem is that the fake blocks won't blur with the screen after dying.

Is there a way to fix that?

Just_Thomas
Blooper
Blooper
Posts: 190
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: FakeBlocks.lua (Successor to NSMBWalls.lua)

Postby Just_Thomas » Wed Mar 13, 2024 9:13 am

Sambo wrote:
Mon Mar 14, 2022 9:52 pm
Emrals SMBX2 Custom Assets Index does list this with Beta 4 compatibility.
I can not find any issue or anything which broke with beta 5. It simply does work well.
I'm also really impressed by how easy it all is to use.
Also I just wanted to say that this is simply great. It's always far too easy to complain.
(Incidentally, this has NOTHING to do with the quote below, these are 2 different pairs of shoes)
MarioChallengerX2 wrote:
Sun Jan 22, 2023 8:27 pm
Hey, so I like this lua code but I have one problem.
A rooms.lua problem.

Note: It works fine but the problem is that the fake blocks won't blur with the screen after dying.

Is there a way to fix that?
Well, that's one thing. If there are bugs with the core content and you can show them to the dev team (the thread "SMBX2 Beta 5 RELEASE! ➡️ Discussion & bugs here!"), they will probably fix it with a patch or the next beta at the latest (if it's in their power).
Most recent example:
Emral wrote:
Wed Mar 13, 2024 8:44 am
yea the rebounders are pretty garbo in general. someone should rewrite them sometime. like you would think this is stable
(at this point it does sound like it is within their power, but I can not say anything about the priority)

When it comes to bugs (or inconsistencies) in "additional npc/lua content", it's a different story. It depends on the respective creator/author whether something happens (to put it bluntly).
It gets really "nasty" when it comes to troubleshooting between 2 different "additional content packs", especially which might also come from different authors. You have practically no chance of a bug fix. That's just the way it is. Exceptions prove the rule, but as a rule it just doesn't happen any other way.
I don't want to offend anyone or show a lack of gratitude or anything like that, but just because there is a bug somewhere and you can prove and show it, it doesn't mean that it will or can be fixed. If you look at the additional content (SMBX2 Custom Assets Index) so far, it's practically impossible for everything to work together.
In your specific case, this means either "FakeBlocks" or "Rooms", but unfortunately not both together.

I've even noticed this with commercial products like Super Dungeon Maker. Somehow everyone knew about a certain bug with the ice surface and vases (their pushing), they had all known about it for a long time. Still not fixed today.

Edit:
BTW: Thanks for bringing "h2643's GFX Pack" to my attention, really looks sick (in a good way of course).


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari