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

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

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

Postby PixelPest » Sat Jun 11, 2016 5:49 pm

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
Last edited by PixelPest on Fri Jul 29, 2016 9:55 am, edited 9 times in total.

Enchlore
Spike
Spike
Posts: 272
Joined: Thu May 08, 2014 3:40 pm

Re: SMG Comet Missions in SMBX!

Postby Enchlore » Sat Jun 11, 2016 6:36 pm

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.

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX!

Postby PixelPest » Sat Jun 11, 2016 6:51 pm

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

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

Re: SMG Comet Missions in SMBX!

Postby Emral » Sat Jun 11, 2016 7:37 pm

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

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX!

Postby PixelPest » Sat Jun 11, 2016 8:09 pm

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

S1eth
Swooper
Swooper
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: SMG Comet Missions in SMBX!

Postby S1eth » Sat Jun 11, 2016 8:36 pm

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.

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX!

Postby PixelPest » Sat Jun 11, 2016 9:40 pm

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

Circle Guy
Rocky Wrench
Rocky Wrench
Posts: 645
Joined: Mon Jan 04, 2016 9:25 pm

Re: SMG Comet Missions in SMBX!

Postby Circle Guy » Sat Jun 11, 2016 10:04 pm

maybe this will be in world 7 of SMBXmix

S1eth
Swooper
Swooper
Posts: 54
Joined: Sat Apr 23, 2016 10:44 am

Re: SMG Comet Missions in SMBX!

Postby S1eth » Sat Jun 11, 2016 10:15 pm

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

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX!

Postby PixelPest » Sun Jun 12, 2016 7:11 am

S1eth wrote:
You sound like Hoeloe lol. Anyway, thanks and I'll look at fixing some of the stuff you mentioned
Last edited by PixelPest on Sun Jun 12, 2016 10:24 am, edited 1 time in total.

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Sun Jun 12, 2016 10:20 am

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

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Thu Jun 16, 2016 9:51 pm

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.

Enchlore
Spike
Spike
Posts: 272
Joined: Thu May 08, 2014 3:40 pm

Re: SMG Comet Missions in SMBX! (Update)

Postby Enchlore » Fri Jun 17, 2016 3:48 pm

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?

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Fri Jun 17, 2016 4:28 pm

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

Enchlore
Spike
Spike
Posts: 272
Joined: Thu May 08, 2014 3:40 pm

Re: SMG Comet Missions in SMBX! (Update)

Postby Enchlore » Fri Jun 17, 2016 4:46 pm

Looking forward to it then!

loop
Ninji
Ninji
Posts: 984
Joined: Sun Apr 17, 2016 5:56 pm
Flair: i may be dumb but im not stupid!
Pronouns: he/him/they

Re: SMG Comet Missions in SMBX! (Update)

Postby loop » Fri Jun 17, 2016 6:37 pm

Wished I knew how to use .lua files. How do you create one?
Thanks! ∩˙▿˙∩
Last edited by loop on Fri Jun 17, 2016 9:38 pm, edited 2 times in total.

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Fri Jun 17, 2016 6:47 pm

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

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Mon Jun 20, 2016 5:34 pm

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

PixelPest
Raccoon Mario
Raccoon Mario
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby PixelPest » Tue Jun 21, 2016 8:17 am

As promised: 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

h2643
Birdo
Birdo
Posts: 2890
Joined: Sat Dec 21, 2013 7:23 am
Contact:

Re: SMG Comet Missions in SMBX! (Update)

Postby h2643 » Tue Jun 21, 2016 8:54 am

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!


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari