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?
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Fri Jul 22, 2016 11:27 pm
How do I change what a NPC spawns, like Birdo's eggs turning into turnips? 
|
|
|
|
|
|
|
|
|
-
Radiance
- 2025 Egg Hunter

- Posts: 1354
- Joined: Thu Dec 10, 2015 7:53 am
- Pronouns: he/him
Postby Radiance » Sat Jul 23, 2016 12:25 am
You can't change it since it's the projectile designated for that NPC. Unless customizing the NPC graphic and codes. And I think you could use LunaLua for that.
Sorry, I thought it's in H&S forum.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 6:58 am
Change its ID in a for loop
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 10:53 am
PixelPest wrote:Change its ID in a for loop
I am autistic, so I don't understand.  Can you give an example? 
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 11:07 am
Jayce 777 wrote:PixelPest wrote:Change its ID in a for loop
I am autistic, so I don't understand.  Can you give an example? 
I'm not going to write the code for you, but an example of a for loop is this:
Code: Select all function onTick()
for _, n in pairs(NPC.get(1, -1)) do --for all SMB3 Goombas in all sections
n.speedX = 8; --change their speed along the x-axis to 8
end
end
As stated above in the comments, this would take the speed of all of the SMB3 Goombas (npc-1) in all of the sections and set their speed along the x-axis to 8. What you want to do is check for whatever NPC you want and change it to another instead of changing its speed, so you would do n.id = #; --> # is the ID you want to change it to
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 11:29 am
Thanks. I am a n00b at coding.
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Sat Jul 23, 2016 11:33 am
PixelPest wrote:
As stated above in the comments, this would take the speed of all of the SMB3 Goombas (npc-1) in all of the sections and set their speed along the x-axis to 8. What you want to do is check for whatever NPC you want and change it to another instead of changing its speed, so you would do n.id = #; --> # is the ID you want to change it to
Actually it's not quite as simple as that. Changing the ID won't account for changing any of the data, so the graphic will likely appear incorrectly and the hitbox will be wrong.
It's simpler to kill the NPC and spawn a new one with the ID you want.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 11:39 am
Hoeloe wrote:PixelPest wrote:
As stated above in the comments, this would take the speed of all of the SMB3 Goombas (npc-1) in all of the sections and set their speed along the x-axis to 8. What you want to do is check for whatever NPC you want and change it to another instead of changing its speed, so you would do n.id = #; --> # is the ID you want to change it to
Actually it's not quite as simple as that. Changing the ID won't account for changing any of the data, so the graphic will likely appear incorrectly and the hitbox will be wrong.
I was waiting to see if that issue would come up and then go from there. Your other idea has its own set of issues too though
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Phanto

- Posts: 1465
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Sat Jul 23, 2016 11:43 am
PixelPest wrote:
I was waiting to see if that issue would come up and then go from there. Your other idea has its own set of issues too though
It absolutely will come up.
It does, but they're simpler to resolve as they just involve setting some values after spawning it.
Alternatively, I personally use a function I wrote that makes use of NPCConfig.lua to adjust the necessary values for changing the ID. I'm thinking of adding it to some standard libraries at some point.
Code: Select all local function replaceNPC(npc,id)
npc.id = id;
local w = npcconfig[npc.id].width;
local h = npcconfig[npc.id].height;
npc:mem(0x90, FIELD_DFLOAT, w);
npc:mem(0x88, FIELD_DFLOAT, h);
if(npcconfig[npc.id].gfxwidth ~= 0) then
w = npcconfig[npc.id].gfxwidth;
end
if(npcconfig[npc.id].gfxheight ~= 0) then
h = npcconfig[npc.id].gfxheight;
end
npc:mem(0xB8, FIELD_DFLOAT, w);
npc:mem(0xC0, FIELD_DFLOAT, h);
npc:mem(0xE4, FIELD_WORD, 0);
end
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 2:12 pm
Would this work?
Code: Select all function onLoop()
NPC.get(40,-1)
if NPC.id == 40 then
NPC.id == 210

|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 2:34 pm
Jayce 777 wrote:Would this work?
Code: Select all function onLoop()
NPC.get(40,-1)
if NPC.id == 40 then
NPC.id == 210

No. Not even close really. You don't have a for loop so NPC.get() isn't doing anything, onLoop() should be onTick(), you don't need to test for NPC ID since you are only getting npc-40 from NPC.get(), and you aren't closing the lines with end anywhere
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 3:04 pm
Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id == 210 --turn Birdo Eggs into Rinkas
end
end
How is this? 
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 3:06 pm
Jayce 777 wrote: Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id == 210 --turn Birdo Eggs into Rinkas
end
end
How is this? 
Close. You need to change NPC in NPC.id to n. NPC is the class but n is the instance you're referring to. You also don't have to change the comments. They don't do anything
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 3:13 pm
Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==0,210 --turn Birdo Eggs into Rinkas
end
end
I didn't understand, but I tried. 
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 3:16 pm
Jayce 777 wrote:Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==0,210 --turn Birdo Eggs into Rinkas
end
end
I didn't understand, but I tried. 
Read what I said again. It's probably the simplest instruction ever. This is totally wrong
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 3:21 pm
PixelPest wrote:Jayce 777 wrote:Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==0,210 --turn Birdo Eggs into Rinkas
end
end
I didn't understand, but I tried. 
Read what I said again. It's probably the simplest instruction ever. This is totally wrong
Oops! Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
How is this? 
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sat Jul 23, 2016 3:24 pm
Jayce 777 wrote:PixelPest wrote:Jayce 777 wrote:Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==0,210 --turn Birdo Eggs into Rinkas
end
end
I didn't understand, but I tried. 
Read what I said again. It's probably the simplest instruction ever. This is totally wrong
Oops! Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
How is this? 
Again.
READ. WHAT. I. SAID.
When did I mention player.section. Never
|
|
|
|
|
|
|
|
|
-
loop
- Ninji

- Posts: 984
- Joined: Sun Apr 17, 2016 5:56 pm
- Flair: i may be dumb but im not stupid!
- Pronouns: he/him/they
Postby loop » Sat Jul 23, 2016 3:35 pm
PixelPest wrote:Jayce 777 wrote:PixelPest wrote:
Read what I said again. It's probably the simplest instruction ever. This is totally wrong
Oops! Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
How is this? 
Again.
READ. WHAT. I. SAID.
When did I mention player.section. Never
Whoa, take it easy! I'll just research some codes.
Did research on the Red Birdo, and I came up with this: Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
n.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
I suck at coding.
Oops! forgot the end again!
|
|
|
|
|
|
|
|
|
-
Quantumenace
- Chain Chomp

- Posts: 308
- Joined: Mon Dec 28, 2015 2:17 am
Postby Quantumenace » Sun Jul 24, 2016 5:21 pm
I'd recommend onTickEnd() because that runs after the egg is spawned but before the game draws it. Otherwise the egg will likely appear for a single frame. I'd also recommend altering the egg's npc txt so it doesn't damage the player; not sure it checks collision the frame it's spawned, but that would err on the safe side.
|
|
|
|
|
|
|
|
|
-
PixelPest
- Link

- Posts: 7111
- Joined: Sun Jul 12, 2015 5:38 pm
- Flair: Tamer of Boom Booms
-
Contact:
Postby PixelPest » Sun Jul 24, 2016 7:24 pm
Jayce 777 wrote:PixelPest wrote:Jayce 777 wrote:
Oops! Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
NPC.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
How is this? 
Again.
READ. WHAT. I. SAID.
When did I mention player.section. Never
Whoa, take it easy! I'll just research some codes.
Did research on the Red Birdo, and I came up with this: Code: Select all function onTick()
for _, n in pairs(NPC.get(40, -1)) do --for all Birdo Eggs in all sections
n.id ==210,player.section --turn Birdo Eggs into Rinkas
end
end
I suck at coding.
Oops! forgot the end again!
Okay. I'm going to try to not flip out, but you haven't followed my instructions over and over again and you have absolutely no idea what you're doing. You know absolutely nothing of the basics of coding and keep on just randomly throwing stuff out that will not work. == is used for comparisons and = for declaring. And please explain to me, why do you think player.section needs to be there?
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 1 guest
|