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?
|
|
|
|
-
Kitti and Minni
- Bit
- Posts: 63
- Joined: Thu May 12, 2016 8:09 pm
- Flair: Pixelated Perfection
-
Contact:
Postby Kitti and Minni » Fri Nov 30, 2018 3:35 pm
This is something I realized a bit late, but due to my preferred version of SMBX not being PGE, there's more graphics than the world editor uses, so Is it possible for a code to, when called for, swap the graphics being used for the Path and/or scenery? And if it is possible, could someone possibly make that, since I don't know squat about coding
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Fri Nov 30, 2018 3:38 pm
PGE isn't a version of SMBX. SMBX2 beta 3 uses its editor, but it is not PGE.
You have to use SMBX2 if you want to code, though, since LunaLua is part of SMBX2, and isn't present in older versions.
|
|
|
|
|
|
|
|
|
-
Kitti and Minni
- Bit
- Posts: 63
- Joined: Thu May 12, 2016 8:09 pm
- Flair: Pixelated Perfection
-
Contact:
Postby Kitti and Minni » Fri Nov 30, 2018 6:07 pm
Hoeloe wrote: ↑Fri Nov 30, 2018 3:38 pm
PGE isn't a version of SMBX. SMBX2 beta 3 uses its editor, but it is not PGE.
You have to use SMBX2 if you want to code, though, since LunaLua is part of SMBX2, and isn't present in older versions.
oh, well dang. Guess I'll see about using that then
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg
- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Sat Dec 01, 2018 4:07 am
Since I also need this as well, would
Code: Select all local tile329A = Graphics.loadImage(Misc.resolveFile("alternate tiles/329.png"))
if world.playerX > 188923 and world.playerX < 196952 and world.playerY > 156623 and world.playerY < 162356 then
Graphics.sprites.tile[329].img = tile329A
else
Graphics.sprites.tile[329].img = nil
end
work? This is obviously an example. I know it can be shortened to use a table, but regardless, would this work in the situation? (Numbers are just random 6 digit numbers between the 200.000 to -200.000 range.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9707
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Dec 01, 2018 6:55 am
MECHDRAGON777 wrote: ↑Sat Dec 01, 2018 4:07 am
Since I also need this as well, would ...
work? This is obviously an example. I know it can be shortened to use a table, but regardless, would this work in the situation? (Numbers are just random 6 digit numbers between the 200.000 to -200.000 range.
Depending on the context you're either loading a sprite every frame here or checking world.playerX at load time. If it's the latter, the else block is entirely unnecessary.
In any case, it SHOULD work. If it doesn't, its a bug. If you do implement it though, please use several tables so that the assignment is short and snappy and easy to adjust.
|
|
|
|
|
|
|
|
|
-
MECHDRAGON777
- Pink Yoshi Egg
- Posts: 6422
- Joined: Fri Dec 20, 2013 6:40 pm
- Flair: Nuclear Queen of Reversion.
-
Contact:
Postby MECHDRAGON777 » Sat Dec 01, 2018 7:49 am
Enjl wrote: ↑Sat Dec 01, 2018 6:55 am
MECHDRAGON777 wrote: ↑Sat Dec 01, 2018 4:07 am
Since I also need this as well, would
Code: Select all local tile329A = Graphics.loadImage(Misc.resolveFile("alternate tiles/329.png"))
if world.playerX > 188923 and world.playerX < 196952 and world.playerY > 156623 and world.playerY < 162356 then
Graphics.sprites.tile[329].img = tile329A
else
Graphics.sprites.tile[329].img = nil
end
work? This is obviously an example. I know it can be shortened to use a table, but regardless, would this work in the situation? (Numbers are just random 6 digit numbers between the 200.000 to -200.000 range.
Depending on the context you're either loading a sprite every frame here or checking world.playerX at load time. If it's the latter, the else block is entirely unnecessary.
In any case, it SHOULD work. If it doesn't, its a bug. If you do implement it though, please use several tables so that the assignment is short and snappy and easy to adjust.
I just now realized I forgot the 'function onDraw()' in that code. I would assume I would need a meta-table here in that case.
Code: Select all local GraphicsSwap ={
{minX=188923, maxY=196952, minY=156623, maxY=162356, graphic={
{type=tile, id=329, subType=A},
{type=path, id=32, subType=A},
}},
{minX=176265, maxY=179232, minY=156623, maxY=162356, graphic={
{type=tile, id=329, subType=B},
{type=path, id=12, subType=A},
}},
}
I would assume a table like this would be prefered? (outside of the function onDraw()). I also would assume the if statement and drawing code would also change to this:
Code: Select all function onDraw()
for _,v in pairs(GraphicsSwap) do
if player.x > v.minX and player.y > v.minY and player.x < v.maxX and player.y < v.maxY then
Graphics.sprites.v.type[v.id].img = v.type.v.id.v.subType
end
end
end
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo
- Posts: 1463
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Sat Dec 01, 2018 8:35 am
This wouldn't work. Both type and subType would be nil because the assignment expressions are variable names.
Besides this is a really strange way to go about it anyway.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9707
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sat Dec 01, 2018 9:27 am
If you want to write this code, what you absolutely should do is to make a library that lets users configure them in one simple step:
Step 1: Tile zone objects. Give 4 coordinates, get a tile zone object back that can be used for grouping tile changes.
Looks like this:
Code: Select all local myZone = worldswapper.createZone(name, left, top, right, bottom)
Notice how I said one step. That's because, in general scenarios, this is all you want users to have to do. The name is the key here. Using the name you can dynamically load all images that use the name. Take a zone with name "desert". And in your folder you then put stuff like:
tile-329-desert.png
path-24-desert.png
Find them automatically.
If you need further functionality you can build on the zone object that is returned. Imagine for example myZone.addArea(left, top, right, bottom) which lets you define another rectangle for the specified tiles.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 0 guests
|