This is the place for discussion and support for LunaLua and related modifications and libraries.
Moderator: Userbase Moderators
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?
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Sun Mar 27, 2016 8:14 pm
Though if you're going to use math.random you should put math.randomseed(os.time()) at the beginning of your code. You could also just use rng.lua, which is "more random" and is generally more useful.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sun Mar 27, 2016 8:15 pm
HenryRichard wrote:Though if you're going to use math.random you should put math.randomseed(os.time()) at the beginning of your code.
Or you could use RNG
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Sun Mar 27, 2016 8:16 pm
Yeah... just like I said...
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sun Mar 27, 2016 8:19 pm
HenryRichard wrote:Yeah... just like I said...
I don't see the point in trying to salvage math.random's functionality if using rng is just so much easier.
Code: Select all local rng = API.load("rng")
local randomVariable = rng.random(1, 10)
http://wohlsoft.ru/pgewiki/Rng.lua
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Sun Mar 27, 2016 10:35 pm
Is there an easy-ish way I could render a bunch of sprites in 3-Dimensional space? I want some that face the camera and some that have a fixed orientation (that is, they don't move with the camera), though I can make do with only the former.
|
|
|
|
|
|
|
|
|
-
Quantumenace
- Chain Chomp

- Posts: 308
- Joined: Mon Dec 28, 2015 2:17 am
Postby Quantumenace » Mon Mar 28, 2016 2:11 am
Sort of. To manipulate a sprite like that you can draw a pair of triangles that use the sprite graphic as a texture. Not sure if you can load the default gif images like that though, it says only to use png.
Edit:Oops, I forgot you already made the level with spinning planets so you know that already. What type of rotation do you mean, is it like a parallax thing?
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Mon Mar 28, 2016 4:29 pm
I don't think you understand what I mean. I want to make a 3D space and draw sprites in it. I'm sure it would utilize some OpenGL functions, though I'm really not sure how to go about it.
|
|
|
|
|
|
|
|
|
-
Quantumenace
- Chain Chomp

- Posts: 308
- Joined: Mon Dec 28, 2015 2:17 am
Postby Quantumenace » Mon Mar 28, 2016 4:55 pm
If you're asking whether the GL functions actually have support of x,y,z coordinates I have no idea. My point is, you can get a 3D perspective by applying a parallax transform to your coordinates.
Code: Select all angle = 0
bb = Graphics.loadImage("bb.png")
function onCameraUpdate()
local cam = Camera.get()[1]; local x0 = cam.x+0.5*cam.width; local y0 = cam.y+0.5*cam.height
local basedepth = 1000
local priority = -96
local texture = bb
local w,h = 128,128
angle=angle+math.pi/90; if angle > math.pi then angle = angle -2*math.pi end
local s = math.sin(angle); local c = math.cos(angle)
local wc = 0.5*w*c; local ws = 0.5*w*s; local hc = 0.5*h*c; local hs = 0.5*h*s
local x,y,z=-199280,-200288,256
local xyz = {x-wc,y+0.5*h,z-ws,x+wc,y+0.5*h,z+ws,x+wc,y-0.5*h,z+ws,
x-wc,y+0.5*h,z-ws,x-wc,y-0.5*h,z-ws,x+wc,y-0.5*h,z+ws}
local xy = {}
for i=1,#xyz,3 do
z=math.max(xyz[i+2],-basedepth+.01)
table.insert(xy,0.5*cam.width+(xyz[i]-x0)*basedepth/(z+basedepth))
table.insert(xy,0.5*cam.height+(xyz[i+1]-y0)*basedepth/(z+basedepth))
end
local txs = {0,1,1,1,1,0,0,1,0,0,1,0}
Graphics.glDraw{texture=texture, textureCoords=txs,vertexCoords=xy, priority=priority}
end
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon Mar 28, 2016 5:28 pm
Quantumenace wrote:If you're asking whether the GL functions actually have support of x,y,z coordinates I have no idea.
They don't. I was, however, working on a 3D renderer a while ago, but it was too slow to be of any use. I got rid of all the old videos I had of it, but it was very basic. Essentially I could load in a .obj file and move it around a 3D scene, but more than about 200 triangles dropped the framerate far too much to be useful.
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Mon Mar 28, 2016 5:36 pm
You wouldn't happen to have any of that code anymore, would you? I probably won't be needing anywhere near 200 triangles for what I'm doing (probably 50 at most) and I may be able to salvage it.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Mon Mar 28, 2016 6:20 pm
HenryRichard wrote:You wouldn't happen to have any of that code anymore, would you? I probably won't be needing anywhere near 200 triangles for what I'm doing (probably 50 at most) and I may be able to salvage it.
Ehhh... it has other problems as well. I still have the library around somewhere, but it's not designed for layering sprites, more for actual perspective 3D projection. Think N64.
|
|
|
|
|
|
|
|
|
-
pal4
- Swooper

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Tue Mar 29, 2016 6:16 pm
I tried to pull off a lunalua code for a real red birdo complete with behavior from Pge wiki. It uses a "simple" lunalua code to make Birdo randomly shoot fireballs in place of eggs. The code looks like this:
local hasGenerated = false;
local ran;
function onLoop()
tableOfBirdo = NPC.get(39, -1);
tableOfBirdoEggs = NPC.get(40, -1);
if(tableOfBirdo[1] ~= nil) then
if(tonumber(tableOfBirdo[1]:mem(0xF0, FIELD_DFLOAT)) == 1) then
if(hasGenerated ~= true) then
ran = math.random(0, 2);
hasGenerated = true;
end
if(ran == 2) then
if(table.getn(tableOfBirdoEggs) > 0) then
tableOfBirdoEggs[table.getn(tableOfBirdoEggs)].id = 282;
playSFX(42);
end
end
end
if(tonumber(tableOfBirdo[1]:mem(0xF8, FIELD_DFLOAT)) == 280) then
hasGenerated = false;
end
end
end
Unfortunately, Birdo is only changed visually; his behavior isn't changed in any way. He still shoots nothing but eggs. Even after copying and pasting the proper code (the downloaded code looks nothing like this), constantly saving my level with the code, and trying to update smbx to match the version of lunalua, still nothing changes!
|
|
|
|
|
|
|
|
|
-
HenryRichard
- Reznor

- Posts: 2843
- Joined: Mon Dec 23, 2013 12:09 pm
- Flair: Is this where I type my password?
-
Contact:
Postby HenryRichard » Tue Mar 29, 2016 10:09 pm
Show us a screenshot of the folder that the level is in.
|
|
|
|
|
|
|
|
|
-
pal4
- Swooper

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Thu Mar 31, 2016 7:28 pm
HenryRichard wrote:Show us a screenshot of the folder that the level is in.
How do I do that?
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Thu Mar 31, 2016 7:31 pm
pal4 wrote:HenryRichard wrote:Show us a screenshot of the folder that the level is in.
How do I do that?
Use snipping tool, another screenshot tool, or the "Print Screen" button on your keyboard to take a screenshot of the folder the level it's in and then upload it to imgur.com
|
|
|
|
|
|
|
|
|
-
pal4
- Swooper

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Fri Apr 01, 2016 5:05 pm
PixelPest wrote:Use snipping tool, another screenshot tool, or the "Print Screen" button on your keyboard
Unfortunately I don't have any tools in my folders and no printer. So I can't do any of those.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Fri Apr 01, 2016 5:07 pm
pal4 wrote:PixelPest wrote:Use snipping tool, another
Unfortunately I don't have any tools in my folders and no printer. So I can't do any of those.
Snipping Tool is a program which comes preinstalled on Windows operating systems since vista. I doubt you don't have it.
|
|
|
|
|
|
|
|
|
-
pal4
- Swooper

- Posts: 63
- Joined: Wed Dec 23, 2015 7:57 pm
Postby pal4 » Fri Apr 01, 2016 5:11 pm
Er, how go I upload a picture on these forums?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg

- Posts: 9890
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Fri Apr 01, 2016 5:16 pm
|
|
|
|
|
|
|
|
|
-
Ness-Wednesday
- Purple Yoshi Egg

- Posts: 1663
- Joined: Sun Jun 28, 2015 3:50 pm
- Flair: Diverse Scouts
- Pronouns: He/Him
Postby Ness-Wednesday » Sat Apr 02, 2016 4:05 pm
What does it mean if I get an error saying that ( is expected near if?
This doesn't make sense to me.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 8 guests
|