Page 1 of 6

Help Thread

Posted: 19 Mar 2015, 21:40
by Zygl
Get help making SMBX behave desirably here.

Re: Help Thread

Posted: 19 Mar 2015, 22:53
by Dragon Fogel
Since people found this explanation of mine from the MAGL X2 thread helpful, I'm going to repost it here. This covers basic stuff that I worked out while making my first level in SMBX.
Dragon Fogel wrote:Hello! I'm a new-to-SMBX person who learned a lot about events and layers in the making of my level, so I'll try to help you other new people out. I used Wohl's editor to learn all this, so my explanations will be based on that.

First, layers. You can make a new layer in one of two ways: by hitting the Layer icon in the top menu (it's the colored rectangles, between the doors and the clock-and-gears), and selecting "New Layer"; or, by right-clicking on something you've placed, hovering over where it says "Layer", and selecting "Add to new layer".

Layers are essentially a number of objects that are all connected. They're either all showing or all not showing. By themselves, they don't really do anything; to make use of them, you need events. So let's talk about those next.

The icon with the clock and gears is the Event icon. Click on that and you'll be able to make new events. There are a few things you can do with them, but the ones I found particularly useful were these:
-Layers.
Probably the most important event feature of all. This lets you select layers to hide, show, or switch between visible and invisible. (The last one is called "Toggle".) At the top is a list of all the layers. Below that are empty lists that say Show, Hide, and Toggle. Highlight a layer in the first list, and click the "+" button next to the list you want it to be in to add it to that list. As an example, you can have a layer called "Star", and put a star in there; then highlight "Star" in the list of layers and click on the "+" button next to Show. This will make everything on the Star layer appear when the event is triggered. Use the Hide list to make layers disappear, and the Toggle list to make them switch between visible and invisible whenever the event happens.
-"Common"
This tab has one feature that I would particularly like to note - "Display message". This makes a message pop up when the event starts. You can use this to show text without requiring the player to talk to an NPC, or to have extra text boxes on talking. This brings us to our next useful feature.
-Trigger event.
You can use an event to call another event. There's only so much you can do with just one, after all. This is most useful for talking; just make a new event for each text box, and have each text box's event trigger the next one. It has other uses, but this is probably the one that will come up the most.

I think that covers the basics, but wait! You might be asking how you make these events happen. Obviously you can use Trigger Event, but that doesn't do you any good unless you've triggered the first event in the sequence, right? So what are your options?

Well, you have four. They're all useful in their own ways. To use any of these, first you place an NPC. You then get a little toolbar that pops up, which you can also see by right-clicking the NPC and selecting Properties. At the bottom of this toolbar, there are four options. These allow the NPC to trigger events under certain circumstances.

-Activate
This causes the event to happen as soon as the player gets close enough for the NPC to spawn. Doesn't work with things like vines or ladders, which don't really "spawn" per se. An example of this would be an enemy that makes a barrier appear behind you when you approach, so you can't leave the area until you defeat it.
-Death
Particularly relevant to Kitet's question! This causes the event to happen once the NPC dies - this includes being collected in the case of items. Again, doesn't work with things like vines or ladders because they can't die.
-Talk
This requires the NPC to be friendly, I believe, so that you can talk to them. It makes something happen when you talk; you can use this for multiple text boxes in a conversation, or to have someone who opens a path or makes a power-up appear when you talk to them.
-Layer is empty
This causes the event to activate if there's nothing left on a specific layer. Examples of this are putting a group of enemies on a layer and making something happen if you defeat them all, or putting all the dragon coins on a layer and making something happen if they're all collected.

It's worth noting that projectiles created by NPCs or anything produced by a generator on a particular layer is not counted as being on that layer. I think they're on Spawned NPCs, which I just realized can be hidden and I didn't think to make use of in my level. Oh well!

I hope that's helpful to other new people, feel free to ask questions about it.

Re: Help Thread

Posted: 20 Mar 2015, 04:00
by Dog In Da Grass
I've been finding all sorts of ways of exploiting the vanilla SMBX to get around the imitations (for the most part at least) so I could potentially help with some more advanced stuff if you have any ideas you were wanting to get working. feel free to PM me or message here too if needed.

Re: Help Thread

Posted: 20 Mar 2015, 14:59
by TaviTurnip
Okay so... are NPCs (or at least flying Koopas set to fly mode) not affected by layer movement? Or is this a side effect of autoscroll? I really wanted to do a specific thing, but it seems like I can only make blocks be affected by layer movement and these Koopas don't care at all. Is that something I'm just stuck without?

Re: Help Thread

Posted: 20 Mar 2015, 15:00
by Rednaxela
I may be mistaken, but I think that the only "NPCs" affected by layer movement are: 1) vines, 2) grabbable grass/herbs

Re: Help Thread

Posted: 20 Mar 2015, 15:15
by TaviTurnip
Rednaxela wrote:I may be mistaken, but I think that the only "NPCs" affected by layer movement are: 1) vines, 2) grabbable grass/herbs
Apparently coins are too, but... this is kind of a letdown, apparently literally everything I wanted for this level is not a thing SMBx does and I'm going to have to do some major trickery/loopholes just to get a level that's even close to what I originally wanted...

You won't beat me, SMBx >:I

Re: Help Thread

Posted: 22 Mar 2015, 03:00
by Dragon Fogel
If I want to have an exit pipe come on-screen, what's the right way to do it? I tried putting a warp next to the pipe on the same layer and moving the layer in an event, but then I died after entering the pipe. Should I put the warp next to where I want the pipe to end up instead?

Re: Help Thread

Posted: 22 Mar 2015, 03:45
by Alice
Dragon Fogel wrote:If I want to have an exit pipe come on-screen, what's the right way to do it? I tried putting a warp next to the pipe on the same layer and moving the layer in an event, but then I died after entering the pipe. Should I put the warp next to where I want the pipe to end up instead?
I could be mistaken but this sounds like it's the moving layers killing you so you may not be able to do a pipe that way. You might try a door if possible instead.

Re: Help Thread

Posted: 22 Mar 2015, 03:52
by Dragon Fogel
The layer isn't moving any more at that point, though. Unless SMBX thinks it is for some reason?

Anyways, I've seen the exact thing I'm trying to do work before, I just don't know what I'm doing wrong with it.

Re: Help Thread

Posted: 22 Mar 2015, 04:09
by Holy
Is the exit warp moving out of position? That's the only thing I can think of.

Re: Help Thread

Posted: 22 Mar 2015, 04:13
by Dragon Fogel
Oh, that might explain it, and apparently I can't have the entrance and exit on different layers so I have to move the exit to the right of where I want it to end up.

Edit: Yeah, that's it. Now the issue is making the exit line up properly. I'm not quite sure how setting the speed in the layer movement command works, in that I know how to change it but I don't know how to make sure it moves a whole number of tiles.

Re: Help Thread

Posted: 22 Mar 2015, 05:15
by Rednaxela
Dragon Fogel wrote:Edit: Yeah, that's it. Now the issue is making the exit line up properly. I'm not quite sure how setting the speed in the layer movement command works, in that I know how to change it but I don't know how to make sure it moves a whole number of tiles.
I'm going to guess the speed is pixels per frame, and each frame is 1/65th of a second so say... speed 4 would mean 260 pixels per second. For sake of fun example, least common multiple of 32 and 65 is 2080 so if you wanted time/speed/tiles to all be integers, would require a movement of 2080 pixels (32 speed, 1 second, 65 tiles)

Re: Help Thread

Posted: 22 Mar 2015, 05:21
by Dragon Fogel
I'm using Wohl's editor, which says "blocks per second" but that doesn't seem to match up with how it's actually working.

Re: Help Thread

Posted: 22 Mar 2015, 05:31
by KingTwelveSixteen
Dragon Fogel wrote:I'm using Wohl's editor, which says "blocks per second" but that doesn't seem to match up with how it's actually working.
It also has a 'how many blocks per second' and 'block pixel size' bits, are either of those off of the default for you? (32 pixels, 1.0000 blocks per second)

Re: Help Thread

Posted: 22 Mar 2015, 05:40
by Rednaxela
KingTwelveSixteen wrote:
Dragon Fogel wrote:I'm using Wohl's editor, which says "blocks per second" but that doesn't seem to match up with how it's actually working.
It also has a 'how many blocks per second' and 'block pixel size' bits, are either of those off of the default for you? (32 pixels, 1.0000 blocks per second)
Note that the blocks per second calculator of Wohl's editor limits it's output to 5 decimal places, so (32 pixels, 1.0000 blocks per second) becomes 0.49231... which if you translate it back to blocks per second gives you 1.0000047 blocks per second. This discrepancy can be enough to impact the SMBX physics if your level is designed as to be super picky about exact block sizes (such as if you put 32px high spikes layered around 32px aligned blocks and stop layer movement right when they cross).

Re: Help Thread

Posted: 22 Mar 2015, 05:48
by Dragon Fogel
Well, that could explain some of the issues I'm having. But there's one other thing - when I set the speed to -6 bps in an event that runs for 1 second before triggering an event that sets the speed to 0, the pipe moves considerably more than 6 blocks. Nearly twice as much.

Setting the event to run for a half-second produces results closer to what I want, but it still makes the layer move an uneven number of blocks. (Probably due to the rounding.)

So is there a good way to make a layer move an exact number of blocks? There are other ways I can do this so it's not that big of a deal, I'm just wondering if I can get this method to work.

Re: Help Thread

Posted: 23 Mar 2015, 06:38
by Dog In Da Grass
Is it possible to start an event after grabbing a stopwatch down from your reserve power-ups? I had an idea where it could be used similarly to a p-switch but I'm not sure if my idea is valid or could work.

Re: Help Thread

Posted: 26 Mar 2015, 11:40
by No Lynch
Is there a way to force a character to enter a level in a certain state (like, say, Small Toad)? Or is that something I should figure out how Lua works for?

Re: Help Thread

Posted: 26 Mar 2015, 12:27
by Rednaxela
No Lynch wrote:Is there a way to force a character to enter a level in a certain state (like, say, Small Toad)? Or is that something I should figure out how Lua works for?
There are of course map making tricks you could use to force a certain powerup state (i.e use a warp to teleport them onto powerups in an area they can't get out of safely ), but they can be a bit messy...

To do it automatically/quietly/clearly without such stuff requires LunaDLL (Either Lua or Autocode).

For sake of a quick code sample for Lua, to force a player to small when entering a the first section:

Code: Select all

function onLoadSection0(playerIndex)
    player.powerup = PLAYER_SMALL
end
To do so for a different section, replace that "0" with a higher number. For more information to learn, one would probably want to start with this howto, and move on to the other documentation, and of course there's the Lua help thread.

Re: Help Thread

Posted: 30 Mar 2015, 14:50
by S1eth
Is there a way to edit blocks to animate (frames and frame speed) like you do with NPCs?

I'm using those moving spikes from Super Metroid, but the ceiling spikes (=Muncher replacement) animate twice as fast as the floor spikes (=Drilling Spikes replacement)

Re: Help Thread

Posted: 30 Mar 2015, 15:12
by Rednaxela
S1eth wrote:Is there a way to edit blocks to animate (frames and frame speed) like you do with NPCs?
Not really no. For blocks you're stuck using ones that already match the desired graphics properties

In theory it might be doable with LunaLua mem calls, but the information required is not yet known.

Re: Help Thread

Posted: 30 Mar 2015, 16:01
by Dog In Da Grass
Is it possible to start an event after grabbing a stopwatch down from your reserve power-ups? I had an idea where it could be used similarly to a p-switch but I'm not sure if my idea is valid or could work.

Re: Help Thread

Posted: 30 Mar 2015, 16:16
by Rednaxela
Dog In Da Grass wrote:Is it possible to start an event after grabbing a stopwatch down from your reserve power-ups? I had an idea where it could be used similarly to a p-switch but I'm not sure if my idea is valid or could work.
Whoops, I saw you post this a few times when I was busy and forgot to respond.

So you want to detect the time freeze and trigger an event? I think this should be doable with LunaLua using a mem call. I'll have to check if the time freeze status memory address is known though. I'll check that tonight.

Re: Help Thread

Posted: 30 Mar 2015, 16:23
by Dog In Da Grass
Rednaxela wrote:
Dog In Da Grass wrote:Is it possible to start an event after grabbing a stopwatch down from your reserve power-ups? I had an idea where it could be used similarly to a p-switch but I'm not sure if my idea is valid or could work.
Whoops, I saw you post this a few times when I was busy and forgot to respond.

So you want to detect the time freeze and trigger an event? I think this should be doable with LunaLua using a mem call. I'll have to check if the time freeze status memory address is known though. I'll check that tonight.
Okay, thanks, sorry I had to double post it :P

Re: Help Thread

Posted: 31 Mar 2015, 12:22
by Rednaxela
Dog In Da Grass wrote:Okay, thanks, sorry I had to double post it :P
Don't have time to test right now but something like

Code: Select all

local event_triggered = false

function onLoop()
	if (mem(0xB2C8B4, FIELD_WORD) ~= 0) then
		if (not event_triggered) then
			event_triggered = true
			triggerEvent("SomeEvent")
		end
	else
		event_triggered = false
	end
end
May works...