Page 1 of 3

Super Mario Galaxy Modder in SMBX! (smgModder.lua 2.0.1.1)

Posted: Sat Jun 11, 2016 5:49 pm
by PixelPest
smgModder.lua is an API that takes a good number of featurs in Super Mario Galaxy and imports them into SMBX. Currently, this includes Daredevil Runs, Purple Coins Runs, a custom HUD, Speed Runs, and an SMG-styled 3-life power-up system. There is a demo included in the download, as well as PDFs of the Changelog and Documentation which are also included below. A video of the demo level is also shown below. As shown in the changelog, this most recent update incorporates the following in addition to all previous features:
  • Bugfix (life counter now works).
In the next update, I plan to add the following, as also shown in the changelog, plus some other things if I come up with othe ideas, bugfix opportunities, and/or recommendations from others:
  • Add Romp Run (SMG2).
  • Add customization support for HUD icons.
  • Add infinitely counting-up coin/starbit counter option.
  • Add health coin option (collect coins to gain health).
  • Add option to play the SMG music for daredevil runs, purple coins missions, speed runs, romp runs, and power-ups when they are activated/collected without the player having to add the music themselves.
Video of the demo level:


Download file (.zip): https://www.dropbox.com/s/wqjkt1xa456l0 ... a.zip?dl=0
Documentation (.pdf): https://www.dropbox.com/s/914pmyxhozgxt ... n.pdf?dl=0
Changelog(.pdf): https://www.dropbox.com/s/vo2sv7pobf60s ... g.pdf?dl=0

Please give feedback and ideas! I want to improve the code itself and want more ideas of features that could be added. Even if they're not from SMG or SMG2 and are of your own imagination, I'd like to hear them

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 6:36 pm
by Enchlore
Great work! This will be very useful for me. Thanks a lot!

As for a suggestion, maybe a comet that replaces a certain NPC with another would be a good idea? Like trading Goombas for Spinies when the comet hits the level.

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 6:51 pm
by PixelPest
Enchlore wrote:Great work! This will be very useful for me. Thanks a lot!

As for a suggestion, maybe a comet that replaces a certain NPC with another would be a good idea? Like trading Goombas for Spinies when the comet hits the level.
Thanks! I might look into adding something like that

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 7:37 pm
by Enjl
Why not move the onNPCKill and onTick into the API and only have a variable for "is the daredevil run active" which the player can set in their level's lua:

Code: Select all

local galaxyComets = API.load("galaxyComets")
galaxyComets.daredevilActive = true

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 8:09 pm
by PixelPest
Enjl wrote:Why not move the onNPCKill and onTick into the API and only have a variable for "is the daredevil run active" which the player can set in their level's lua:

Code: Select all

local galaxyComets = API.load("galaxyComets")
galaxyComets.daredevilActive = true
The code with onTick() and onNPCKill() was just an example of one of the many things you can do with it. Although it's an interesting idea, I think I'll keep it the way I have it due to the other two parameters (they're set to false by default which is why I didn't use them in the example). Thanks for the suggestion though

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 8:36 pm
by S1eth
PixelPest wrote:
Enjl wrote:Why not move the onNPCKill and onTick into the API and only have a variable for "is the daredevil run active" which the player can set in their level's lua:

Code: Select all

local galaxyComets = API.load("galaxyComets")
galaxyComets.daredevilActive = true
The code with onTick() and onNPCKill() was just an example of one of the many things you can do with it. Although it's an interesting idea, I think I'll keep it the way I have it due to the other two parameters (they're set to false by default which is why I didn't use them in the example). Thanks for the suggestion though
http://hastebin.com/idujiwihad.lua

You can thank me later.

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 9:40 pm
by PixelPest
S1eth wrote:
PixelPest wrote:
Enjl wrote:Why not move the onNPCKill and onTick into the API and only have a variable for "is the daredevil run active" which the player can set in their level's lua:

Code: Select all

local galaxyComets = API.load("galaxyComets")
galaxyComets.daredevilActive = true
The code with onTick() and onNPCKill() was just an example of one of the many things you can do with it. Although it's an interesting idea, I think I'll keep it the way I have it due to the other two parameters (they're set to false by default which is why I didn't use them in the example). Thanks for the suggestion though
http://hastebin.com/idujiwihad.lua

You can thank me later.
Um. Okay. Why should I use this though? It's about twice as long as my code. I'm not saying no thank you, I'm just wondering why this is so much better even though it's much less concise

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 10:04 pm
by Circle Guy
maybe this will be in world 7 of SMBXmix

Re: SMG Comet Missions in SMBX!

Posted: Sat Jun 11, 2016 10:15 pm
by S1eth
PixelPest wrote:
S1eth wrote:
PixelPest wrote: The code with onTick() and onNPCKill() was just an example of one of the many things you can do with it. Although it's an interesting idea, I think I'll keep it the way I have it due to the other two parameters (they're set to false by default which is why I didn't use them in the example). Thanks for the suggestion though
http://hastebin.com/idujiwihad.lua

You can thank me later.
Um. Okay. Why should I use this though? It's about twice as long as my code. I'm not saying no thank you, I'm just wondering why this is so much better even though it's much less concise
There are a number of reasons.

1. It can be used in levels like this:

Code: Select all

local galaxyComets = API.load("galaxyComets");
galaxyComets.daredevil.activate();
And this is your code, for comparison

Code: Select all

local galaxyComets = API.load("galaxyComets");

local var = true;

function onTick()
   if var then
      galaxyComets.daredevilRun();
   else
      galaxyComets.daredevilRun(false);
   end
end
Your code is a total disaster. If you don't want your daredevilRun to be active, don't call it.
And don't name your important variable "var". Your parents didn't name you "human" when you were born.

2.
It's not full of bugs and unintended side effects like your code is.

You had this line of code:

Code: Select all

registerEvent(galaxyComets, "onTick", "daredevilRun", "purpleCoinsRun", false);


It is pretty clear that you do not understand what registerEvent does.
Your function has 5 arguments, but registerEvent only allows for four arguments.
Your last argument is ignored.
And "purpleCoinsRun" is NOT registered.
Instead, you are using "purpleCoinsRun" in place of false, but the string evaluates to TRUE, which means that your registered event "daredevilRun" will be execated every tick before the onTick() function.

Secondly, this code calls daredevilRun() automatically every tick with no arguments.
And in addition to that, you wrote some code that calls this function A SECOND TIME every frame.
Even if you have var = false, you call it once as if it were true, and a second time as if it were false.
That's just not how coding works.

On top of that, you have a "firstTick" part, but you don't turn it off after the first tick.
And when it is turned off, you forgot to turn it back on when you activate the run a second time.

3.
Readability and maintainability.

Multiple small well-named functions are better than one big function.
I wrote functions for activating and deactivating your run, which sets up all varaibles for the user.
We only execute code when we need to. We don't mute the audio every single frame even though it is already muted, for example.

4.
Maybe studying this will make you learn how to properly write code.
Maybe you will finally look up how registerEvent works.
Maybe you will stop using snippets of code you don't understand.
Maybe

Re: SMG Comet Missions in SMBX!

Posted: Sun Jun 12, 2016 7:11 am
by PixelPest
S1eth wrote:
You sound like Hoeloe lol. Anyway, thanks and I'll look at fixing some of the stuff you mentioned

Re: SMG Comet Missions in SMBX! (Update)

Posted: Sun Jun 12, 2016 10:20 am
by PixelPest
Update
  • Optimized code.
  • Variables now accessed instead of inputting them into a function.
  • Four functions now instead of two.
  • Player can no longer access the variables daredevilActive and purpleCoinsActive. (Use galaxyComets.daredevilActivate(), galaxyComets.daredevilDeactivate(), galaxyComets.purpleCoinsActivate(), and/or galaxyComets.purpleCoinsDeactivate().
  • Documentation updated, including examples.
And thank you to S1eth who played a big part in helping make this better!

Updated documentation:

Daredevil Run
Makes the player Big Mario, but only gives them one life.

Functions the player can access:
galaxyComets.daredevilActivate() --> activates the mission and its effects
galaxyComets.daredevilDeactivate() --> deactivates the mission and its effects

Variables the player can access:
galaxyComets.daredevilAllowPowerups --> Boolean --> when true allows the player to collect power-ups, however they will still die if hurt (default: false)
galaxyComets.daredevilDebug --> Boolean --> when true displays the text "Daredevil run active." in the bottom left corner of the screen (default: false)

Example:

Code: Select all

local galaxyComets = API.load("galaxyComets");

function onStart()
	galaxyComets.daredevilActivate();
	galaxyComets.daredevilDebug = true;
end
Purple Coins Run
Creates a purple coins mission.

Functions the player can access:
galaxyComets.purpleCoinsRunActivate() --> activates the mission and its effects
galaxyComets.purpleCoinsRunDeactivate() --> deactivates the mission and its effects

Variables the player can acccess:
galaxyComets.purpleCoinsLayer --> Layer --> The layer containing the purple coins (should be hidden by default and will be shown when this function is run) (default: Layer(3): the first custom layer)
galaxyComets.purpleCoinsIdent --> Int --> the ID of the NPC to be collected as the mission (default: 88 (SMB1 coin))
galaxyComets.purpleCoinsNumber --> Int --> the number of the chosen coin NPC that needs to be collected to complete the mission (default: 100)
galaxyComets.purpleCoinsLimit --> Int or nil --> the time limit the player has to collect all of the coins to complete the mission before they die. Changing this value to nil will bypass the creation of a timer (default: 150)
galaxyComets.purpleCoinsNoSmoke --> Boolean --> whether or not the smoke effect should be shown when the layer appears (default: true)
galaxyComets.purpleCoinsSFX --> Int --> the numeric ID of an SMBX sound that should be played to signal that the mission is complete (default: nil)
galaxyComets.purpleCoinsDebugActive --> Boolean --> when true displayed the text "Purple coins run active." in the bottom left corner of the screen (default: false)
galaxyComets.purpleCoinsDebugCoinsText --> Boolean --> when true displays the text "Purple coins: " and the coin count in the bottom left corner of the screen (default: false)

Example:

Code: Select all

local galaxyComets = API.load("galaxyComets");
local layer6 = Layer(6);

function onStart()
	galaxyComets.purpleCoinsActivate()
	galaxyComets.purpleCoinsLayer = layer6;
	galaxyComets.purpleCoinsNumber = 3;
	galaxyComets.purpleCoinsSFX = 5;
	galaxyComets.purpleCoinsDebugActive = true;
	galaxyComets.purpleCoinsDebugCoinsText = true;
end
Updated downloads:

Download file: https://www.dropbox.com/s/74r0frfy8f5j1 ... s.lua?dl=0
Download text (Hastebin): http://hastebin.com/recowofeho.lua

Re: SMG Comet Missions in SMBX! (Update)

Posted: Thu Jun 16, 2016 9:51 pm
by PixelPest
A really big update is coming soon! The name of this topic will be changed, since the API no longer will solely deal with comet missions, but the whole SMG configuration including:
  • Fully working HUD with customizable features. Includes SMB1, SMB2, SMB3, and SMW styled and recoloured graphics for the HUD elements. The HUD can be toggled on and off at any time and includes the SMG life meter and HUD layout.
  • More settings and options for the Daredevil Run and Purple Coins Run missions.
  • More general settings and options including those regarding power-ups.
  • More (comet) missions added.
  • Name of the API will be changed from galaxyComets.lua to smgModder.lua.

Re: SMG Comet Missions in SMBX! (Update)

Posted: Fri Jun 17, 2016 3:48 pm
by Enchlore
PixelPest wrote:
  • Fully working HUD with customizable features. Includes SMB1, SMB2, SMB3, and SMW styled and recoloured graphics for the HUD elements. The HUD can be toggled on and off at any time and includes the SMG life meter and HUD layout.
Does that include a SMG-style life system or is it purely aesthetic?

Re: SMG Comet Missions in SMBX! (Update)

Posted: Fri Jun 17, 2016 4:28 pm
by PixelPest
Enchlore wrote:
PixelPest wrote:
  • Fully working HUD with customizable features. Includes SMB1, SMB2, SMB3, and SMW styled and recoloured graphics for the HUD elements. The HUD can be toggled on and off at any time and includes the SMG life meter and HUD layout.
Does that include a SMG-style life system or is it purely aesthetic?
Both are options

Re: SMG Comet Missions in SMBX! (Update)

Posted: Fri Jun 17, 2016 4:46 pm
by Enchlore
Looking forward to it then!

Re: SMG Comet Missions in SMBX! (Update)

Posted: Fri Jun 17, 2016 6:37 pm
by loop13
Wished I knew how to use .lua files. How do you create one?
Thanks! ∩˙▿˙∩

Re: SMG Comet Missions in SMBX! (Update)

Posted: Fri Jun 17, 2016 6:47 pm
by PixelPest
Jayce 777 wrote:Wished I knew how to use .lua files. How do you create one?
Create a text file --> Right click (not on the file though) --> Select "Show File Extensions" (may be in Settings, Details, Properties, or on the immediate menu) --> Right click on your text file --> Select "Rename" --> Change .txt to .lua --> Open with Notepad, Notepad++, or a similar program to modify.

EDIT: On another note, almost ready to release a few screenshots

Re: SMG Comet Missions in SMBX! (Update)

Posted: Mon Jun 20, 2016 5:34 pm
by PixelPest
Getting really close to having this done. Just messing around with the HUD a bit to get everything to line up nicely and satisfy my OCD. Other than that, it's pretty much done, so I'll have some screenshots up tomorrow morning (8am EST) on both the screenshot thread and here as well as some more screenshots, the demo level (including a video of it), and the new API hopefully that afternoon

Re: SMG Comet Missions in SMBX! (Update)

Posted: Tue Jun 21, 2016 8:17 am
by PixelPest
As promised:
Spoiler: show
Just need to fix the positioning of a few HUD elements as you can see with the purple coins counter) and then I will release it

Re: SMG Comet Missions in SMBX! (Update)

Posted: Tue Jun 21, 2016 8:54 am
by h2643
I think both the purple coin icon and counter should be a bit lowered closer to the star bit counter. The star bit counter could be moved a bit to the left too closer to the icon. Nice work though!