Share and discuss custom LunaLua code and content packs for SMBX2.
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon May 06, 2019 8:51 am
Ever worked with a tileset that has multiple options for fill tiles or other shenanigans? Don't feel like placing all those SMB2 LEGOs yourself?
Well...
Download:
https://pastebin.com/wX6ipYAA
Screenshot:
tilerandomizer3 is, shockingly, the third edition of this script. I have archived the old version below for those interested, as with the shift to Version 3, the entire script was rewritten.
Example:
Code: Select all local tr3 = require("tilerandomizer3")
tr3.registerBlockTransformation(
16,
{15, 17},
0.1
)
tr3.registerBgoTransformation(
53,
{54, 55, 56, 57},
0.8
)
tr3.registerBgoTransformation(
53,
{84, 85, 86, 89, 90, 91, 93, 94, 95, 96},
0.3
)
tr3.registerSizableAsBGO(
130,
53
)
Changelog:
- Fixed a bug with the RNG seed
- Now uses a fixed RNG seed by default
- Redesigned all functions to be easier to use and more flexible
-- Can now register different lists of randomizations with different chances more easily
- Added a new randomization step: Transforming a sizable into a grid of BGOs of an ID (32x32 only). That BGO can then be randomized by the BGO Transformation step.
- If customcamera is loaded, it will be compatible
Old post:
https://drive.google.com/file/d/19g-JMP ... sp=sharing
New in v2:
- Can alter the RNG seed from external code
- NEW: Can register BGOs to be replaced by other BGOs
- NEW: Can register Blocks to have randomized BGOs attached (pseudo-bgos, not real bgos) that move with the block and get hidden with it.
- NEW: Can add chance and pivot to all registrations
- Incompatible with v1
A usage example is included:
Code: Select all local tr2 = require("tileRandomizer2")
-- Sets the RNG seed. Guaranttes that the randomization is consistent across runs. Change number for different seed.
tr2.rng = RNG(12)
-- Registers block 3 to gain BGOs 1 or 37 at a 50% chance. The BGOs are offset by 32 pixels upwards.
-- Also registers block 272 to gain 84 or 85 at 25% chance. While there is no y-offset, the pivot is set so that this coordinate corresponds to the bottom center of the bgo, and that the block fixation point is the top center of the block.
tr2.registerBlockBGOPairs(
{{3}, {1, 37}, {chance = 0.5, yOffset = -32}},
{{272}, {84, 85}, {chance = 0.25, yOffset = 0, blockpivot = vector(0.5, 0), bgopivot=vector(0.5, 1)}}
)
-- Tells block 16 that it can become any block in the list at a 50% chance
-- Also tells block 3 to transform into block 272.
-- Block transformation happens before BGO registration, meaning the new 272 blocks will get pseudo BGOs as per the above registration.
tr2.registerBlockBlockPairs(
{{16}, {602, 603, 1111, 1112, 1113, 1114}, {chance = 0.5}},
{{3}, {272}, {chance = 0.5}}
)
-- BGO 128 may transform into any of the given IDs at a 75% chance. The pivot is set so that the bottom center is kept the same.
tr2.registerBgoBgoPairs(
{{128}, {84, 85, 127}, {chance = 0.75, pivot = vector(0.5, 1)}}
)
The general pattern is:
Code: Select all registrationCall(
{first registration},
{second registration},
...
)
And each registration is a table like:
Code: Select all {{list of object ids to apply this to}, {list of target IDs to transform into/spawn}, {settings table for chance, pivot...}}
Last edited by Emral on Wed Apr 26, 2023 6:55 am, edited 4 times in total.
|
|
|
|
|
|
|
|
|
-
Eri7
- Banned
- Posts: 1770
- Joined: Sat Jan 28, 2017 4:48 pm
- Flair: Good Foundation allows for strong Execution
-
Contact:
Postby Eri7 » Mon May 06, 2019 2:01 pm
Well damn, i didn't believe this was possible but you just made our lives way, way easier, thanks Enjl.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon May 06, 2019 7:45 pm
Enjl wrote: ↑Mon May 06, 2019 8:51 am
Seed, you ask? Oh yeah. This library uses a standalone instance of rng.lua to ensure your level doesn't magically look different on repeat playthroughs.
This is unnecessary. The version of RNG.lua that exists in the maglx3 build lets you generate RNG objects for precisely this purpose.
You don't even need to load any libraries, it's just:
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon May 06, 2019 7:48 pm
Hoeloe wrote: ↑Mon May 06, 2019 7:45 pm
Enjl wrote: ↑Mon May 06, 2019 8:51 am
Seed, you ask? Oh yeah. This library uses a standalone instance of rng.lua to ensure your level doesn't magically look different on repeat playthroughs.
This is unnecessary. The version of RNG.lua that exists in the maglx3 build lets you generate RNG objects for precisely this purpose.
You don't even need to load any libraries, it's just:
Didn't know about that. I presume this returns the rng object and that object can then be used just like the library itself? myRngObject.irandomEntry, for example.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon May 06, 2019 7:49 pm
Enjl wrote: ↑Mon May 06, 2019 7:48 pm
Didn't know about that. I presume this returns the rng object and that object can then be used just like the library itself? myRngObject.irandomEntry, for example.
Yep. It's a useful feature.
|
|
|
|
|
|
|
|
|
-
Akromaly
- Bronze Yoshi Egg
- Posts: 425
- Joined: Sun Mar 12, 2017 8:07 am
- Flair: anemoia
-
Contact:
Postby Akromaly » Wed May 08, 2019 9:14 am
|
|
|
|
|
|
|
|
|
-
Eri7
- Banned
- Posts: 1770
- Joined: Sat Jan 28, 2017 4:48 pm
- Flair: Good Foundation allows for strong Execution
-
Contact:
Postby Eri7 » Wed May 08, 2019 1:03 pm
IIRC he did state he likes watching CarlSagan42 who is mario maker focused youtuber.
|
|
|
|
|
|
|
|
|
-
krakin
- Birdo
- Posts: 2890
- Joined: Sun Dec 11, 2016 8:02 pm
- Flair: i wish squids and octos were real
- Pronouns: he/him
-
Contact:
Postby krakin » Wed May 08, 2019 11:22 pm
|
|
|
|
|
|
|
|
|
-
Akromaly
- Bronze Yoshi Egg
- Posts: 425
- Joined: Sun Mar 12, 2017 8:07 am
- Flair: anemoia
-
Contact:
Postby Akromaly » Thu May 09, 2019 8:26 am
Eureka wrote: ↑Wed May 08, 2019 11:22 pm
Don't we all?
definitely lol
|
|
|
|
|
|
|
|
|
-
CatgirlCassie
- Shy Guy
- Posts: 7
- Joined: Wed Nov 25, 2020 8:42 am
- Flair: Wahoo
- Pronouns: she/her
-
Contact:
Postby CatgirlCassie » Sun Nov 29, 2020 1:42 pm
When I try to use this, I get this error, regardless of which tiles I use. Could just be me being a newbie but I have no idea what this means.
|
|
|
|
|
|
|
|
|
-
Shocken Studios
- Rex
- Posts: 32
- Joined: Fri Jul 19, 2019 6:02 pm
- Flair: Hi
Postby Shocken Studios » Tue Dec 22, 2020 12:38 pm
Harmon wrote: ↑Sun Nov 29, 2020 1:42 pm
When I try to use this, I get this error, regardless of which tiles I use. Could just be me being a newbie but I have no idea what this means.
i also get this
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Dec 22, 2020 12:49 pm
Shocken Studios wrote: ↑Tue Dec 22, 2020 12:38 pm
Harmon wrote: ↑Sun Nov 29, 2020 1:42 pm
When I try to use this, I get this error, regardless of which tiles I use. Could just be me being a newbie but I have no idea what this means.
i also get this
Did you load the library?
local tileRandomizer = require("tileRandomizer")
Can't use a library that's not loaded!
|
|
|
|
|
|
|
|
|
-
CatgirlCassie
- Shy Guy
- Posts: 7
- Joined: Wed Nov 25, 2020 8:42 am
- Flair: Wahoo
- Pronouns: she/her
-
Contact:
Postby CatgirlCassie » Tue Dec 22, 2020 7:39 pm
Enjl wrote: ↑Tue Dec 22, 2020 12:49 pm
Shocken Studios wrote: ↑Tue Dec 22, 2020 12:38 pm
Harmon wrote: ↑Sun Nov 29, 2020 1:42 pm
When I try to use this, I get this error, regardless of which tiles I use. Could just be me being a newbie but I have no idea what this means.
i also get this
Did you load the library?
local tileRandomizer = require("tileRandomizer")
Can't use a library that's not loaded!
Ah my mistake lmao, works like a charm. Thanks!
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Wed Dec 30, 2020 4:44 am
Updated to version 2.0, a rewrite from scratch that I used in Subzero Heroes:
Download:
https://drive.google.com/file/d/19g-JMP ... sp=sharing
Screenshot:
New in v2:
- Can alter the RNG seed from external code
- NEW: Can register BGOs to be replaced by other BGOs
- NEW: Can register Blocks to have randomized BGOs attached (pseudo-bgos, not real bgos) that move with the block and get hidden with it.
- NEW: Can add chance and pivot to all registrations
- Incompatible with v1
For more info see the first post.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Wed Dec 30, 2020 10:21 am
Now make a blue noise version.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Jan 07, 2021 10:46 am
Replace RNG(...) in line 3 with RNG.new(...)
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Thu Jan 07, 2021 12:36 pm
Ugh I forgot to push one change to this when I first uploaded it it seems.
Change all instances of "ls.rng." to "ls.rng:" in the file.
|
|
|
|
|
Return to “LunaLua”
|