[Block + NPC Pack] Exclusive Blocks

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Arctangent
Goomba
Goomba
Posts: 3
Joined: Tue May 28, 2019 4:51 pm
Flair: squawky

[Block + NPC Pack] Exclusive Blocks

Postby Arctangent » Tue May 28, 2019 7:30 pm

Image
click to see a gfycat of the switches in action

Toggled blocks that come in four colors and can be toggled between solid and passthrough with a switch NPC or switch block of the same color, but with an added wrinkle: toggling a color on toggles the rest off. Additionally, hitting the switch again won't toggle the color off - once it's on, it'll stay on until another color is toggled on. NOT variations of each block are included, which are solid while their color is off and passthrough when it's on.

Download here!

Installation instructions are as usual, though the blocks need to be registered before use. If you just want to use the defaults, though, you can add require("exclregistry") to your luna.lua and that'll handle that for you.

Configuration:
Spoiler: show
Bit of terminology: the system works off a level's "exclusive state," which persists between sections but is reset when the level starts. The exclusive state can be any valid table key, thought the default blocks and NPC uses integers. An exclusive block is solid when its assigned state is the same as the level's, and a NOT block is solid when it isn't.

Blocks:
If four blocks isn't enough, adding more is as simple as registering the IDs in your exclregistry.lua ( or luna.lua if you're registering the blocks manually ):

Code: Select all

local exclBlock = require("exclblock/exclblock")

exclBlock.registerExclBlockSet(stateID, exlblockID, notblockID, switchblockID)
exclBlock.registerExclBlockSet() accepts nil for everything but stateID, so you don't have to define all three block types if you don't need to. The default blocks use the state ID 1-4, and the level starts at 0.

Switch NPCs:
The switch NPCs have following NPC codes:
pressonce: Boolean. Sets whether the switch NPC is reusable.
grabsidewhilepressed: Boolean. Sets whether the switch NPC can be grabbed while in its pressed state ( though non-reusable switches can't be grabbed after being pressed regardless, as their "corpse" isn't an NPC )
effect: Integer. The effect left behind after a non-reusable switch is pressed.
exclstate: Integer. The exclusive state the switch puts the level in.

These switches also need to be registered through exclSwitch.registerSwitch( npcID ), though the npc-n.lua of the default switches do this for you, so this only matters if you add more.

General:
If you want to start the level with a certain set of blocks toggled on, you can add this to your luna.lua:

Code: Select all

local exclState = require("exclblock/exclstate")

exclState.setExclState(stateID)
exclState.setExclState() can be called at any time to modify the exclusive state. Additionally, you can hook into the onExclStateChange(newState, oldState) event to run code whenever the exclusive state is changed to a different state.
Changelog:
Spoiler: show
v1.0
Created. Includes exclusive blocks, exclusive NOT blocks, exclusive switch blocks, and exclusive switch NPCs.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Block + NPC Pack] Exclusive Blocks

Postby Emral » Wed May 29, 2019 1:10 am

Awesome.

Sluigi123
Hoopster
Hoopster
Posts: 45
Joined: Tue May 20, 2014 4:44 pm
Pronouns: He/Him
Contact:

Re: [Block + NPC Pack] Exclusive Blocks

Postby Sluigi123 » Fri Jun 07, 2019 12:59 pm

I have a feeling that there'll be more puzzles incoming from all fronts! XD

Wiimeiser
Snifit
Snifit
Posts: 215
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: [Block + NPC Pack] Exclusive Blocks

Postby Wiimeiser » Mon Jun 24, 2019 8:23 pm

Okay, how do I go about registering the blocks? Even the require("exclregistry") doesn't work, and the two links you provided tell me nothing about registering them. Maybe this is well above my ability, and I'll just have to settle for them being mere decorative solid blocks...

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Block + NPC Pack] Exclusive Blocks

Postby Emral » Tue Jun 25, 2019 10:51 am

Wiimeiser wrote:
Mon Jun 24, 2019 8:23 pm
Okay, how do I go about registering the blocks? Even the require("exclregistry") doesn't work, and the two links you provided tell me nothing about registering them. Maybe this is well above my ability, and I'll just have to settle for them being mere decorative solid blocks...
Have you tried opening the spoilers at the bottom of the first post?

Arctangent
Goomba
Goomba
Posts: 3
Joined: Tue May 28, 2019 4:51 pm
Flair: squawky

Re: [Block + NPC Pack] Exclusive Blocks

Postby Arctangent » Tue Jun 25, 2019 10:59 am

As another thing, make sure your luna.lua is luna.lua, and not luna.lua.txt. Even if .lua files are just plaintext documents, they rely on that file extension to be recognized as lua code, and if you don't have file extensions shown, it can be pretty difficult to actually make a .lua file.

On the flip-side, if you do have 'em shown, you can just rename a whatever.txt file into a whatever.lua file and it'll work fine. If you haven't done that before, you'll likely have to associate .lua files with your text editor of choice to make it easier to open and edit 'em, but as the two types of files are identical in data format, there's no need for some sort of converter or anything.

Wiimeiser
Snifit
Snifit
Posts: 215
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: [Block + NPC Pack] Exclusive Blocks

Postby Wiimeiser » Tue Jun 25, 2019 8:24 pm

Just pasting require("exclregistry") into an otherwise empty luna.lua just brings up an error, and the blocks still do nothing. Where is it supposed to go in the file? What files am I supposed to modify?

I guess this is well beyond my skill level, I need a university education to understand it, and I should just use something else instead...

EDIT: Perhaps what I need is a sample level.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Block + NPC Pack] Exclusive Blocks

Postby Emral » Wed Jun 26, 2019 3:41 am

Wiimeiser wrote:
Tue Jun 25, 2019 8:24 pm
Just pasting require("exclregistry") into an otherwise empty luna.lua just brings up an error, and the blocks still do nothing. Where is it supposed to go in the file? What files am I supposed to modify?

I guess this is well beyond my skill level, I need a university education to understand it, and I should just use something else instead...

EDIT: Perhaps what I need is a sample level.
Perhaps what we need in order to be more helpful is information on the error. Could you share a screenshot of what it says?

Wiimeiser
Snifit
Snifit
Posts: 215
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: [Block + NPC Pack] Exclusive Blocks

Postby Wiimeiser » Wed Jun 26, 2019 5:24 am

If I just copy the contents of the zip, minus subfolders, into the level folder, I get this error:
Image
And the blocks act like regular solid blocks.
If I delete the NPCs, no error appears, but the blocks are still solid and still do nothing (except spawn an NPC if they're told to, as usual)
If I add the require("exclregistry") to a luna.lua I get this error:
Image
and the blocks are still solid and do nothing.
Just now I put in the local exclState = require("exclblock/exclstate") exclState.setExclState(stateID) snippet and set the state ID to 2, and the error becomes this:
Image
And the blocks are still the same as before.
Am I supposed to put more into the luna.lua than just those individual lines by themselves? Because it looks like that's the case. The first of the latter two times I only had "require("exclregistry") " and nothing else, and the second time all I had was "exclState = require("exclblock/exclstate") exclState.setExclState(2)", and the blocks still didn't work. Looks like they just don't work. The states simply aren't getting set. Is my version outdated? Does anyone have a sample level I could dig through to see exactly what I need to do?

The spoiler doesn't help, all it does is tell me how to add more than 4 block types and to start with one active. The first link takes me to the section "NPC-n.lua Files, NPC Packs and NPC Duplication" in the handbook and the second link takes me to a forum post that doesn't tell me anything useful for this particular situation. What I need is a step-by-step tutorial for this one specific pack, or better, a sample level.

At this point the only thing I can think of to do is actually program the blocks myself from scratch. I might as well not use them at all and just settle for blocks 170-181 from the vanilla game instead. Maybe swap out the graphics with these ones, but that's as far as I'll be able to use them. Alternatively, I could just use them as glorified ? blocks, as that's about all the functionality I can get out of them...

EDIT: I've gone with swapping out the graphics for blocks 170-181 with the defaults for these. I see no other way to get them to work unless someone is willing to send me a sample level with these blocks fully working.

EDIT: Should I upload a level so you can see if I'm doing anything wrong?

EDIT again: While messing around I found installing the first subfolder (the one with the three lua files) makes the switches work as they should, but they won't change the block states at all. As far as I can understand the code, this might mean the state isn't being initialized, the state is currently not a number and must be defined as one or something like that.

EDIT whatever: I think I might have figured out what might be going on, but I'm not so sure...

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: [Block + NPC Pack] Exclusive Blocks

Postby Emral » Wed Jun 26, 2019 7:18 am

Like you figured out in one of your edits, "Minus subfolders" was the issue. You can see in the error messages that, from exclregistry.lua, require is trying to load "exclblock/exclstate", which means "exclstate.lua in the exclblock subfolder". I think the other issue you have might be resolvable in a similar manner. Are you following the installation instruction topic's advice of extracting the ENTIRE archive into the level/episode folder now? If not, please try it.

As for the number state issue: Are you getting another error message? Each error message has unique information about the cause of the error, so it would be very helpful to know if there's a new one. A new lead, in detective speech.

Wiimeiser
Snifit
Snifit
Posts: 215
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: [Block + NPC Pack] Exclusive Blocks

Postby Wiimeiser » Wed Jun 26, 2019 7:39 am

Seems to be working now. Seems I just missed putting the subfolder in as an actual subfolder, which isn't immediately obvious for someone who doesn't understand LunaLua errors...

Though I'm still getting an annoying flashing animation in the editor with the blocks that are nonsolid by default. I think they just need block-###e versions if I'm not mistaken?

MadDest
Goomba
Goomba
Posts: 3
Joined: Tue Jul 23, 2019 4:22 am
Flair: Am I Real?

Re: [Block + NPC Pack] Exclusive Blocks

Postby MadDest » Sat Jul 27, 2019 3:21 pm

Great job! Also, man, how did you make blocks swap? can you show on SMBX, please? :(


Return to “LunaLua”

Who is online

Users browsing this forum: gio_zen, KoragusuMaster and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari