Change projectiles?
Posted: Fri Jul 22, 2016 11:27 pm
How do I change what a NPC spawns, like Birdo's eggs turning into turnips? 

I am autistic, so I don't understand.PixelPest wrote:Change its ID in a for loop
I'm not going to write the code for you, but an example of a for loop is this:Jayce 777 wrote:I am autistic, so I don't understand.PixelPest wrote:Change its ID in a for loopCan you give an example?
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
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.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
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 thoughHoeloe wrote: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.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
It absolutely will come up.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
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 anywhereJayce 777 wrote:Would this work?Code: Select all
function onLoop() NPC.get(40,-1) if NPC.id == 40 then NPC.id == 210
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
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 anythingJayce 777 wrote:
How is this?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
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
Read what I said again. It's probably the simplest instruction ever. This is totally wrongJayce 777 wrote:I didn't understand, but I tried.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
Oops!PixelPest wrote:Read what I said again. It's probably the simplest instruction ever. This is totally wrongJayce 777 wrote:I didn't understand, but I tried.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
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
Again.Jayce 777 wrote:Oops!PixelPest wrote:Read what I said again. It's probably the simplest instruction ever. This is totally wrongJayce 777 wrote:I didn't understand, but I tried.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
How is this?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
Whoa, take it easy! I'll just research some codes.PixelPest wrote:Again.Jayce 777 wrote:Oops!PixelPest wrote: Read what I said again. It's probably the simplest instruction ever. This is totally wrong
How is this?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
READ. WHAT. I. SAID.
When did I mention player.section. Never
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
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?Jayce 777 wrote:Whoa, take it easy! I'll just research some codes.PixelPest wrote:Again.Jayce 777 wrote: Oops!
How is this?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
READ. WHAT. I. SAID.
When did I mention player.section. Never
Did research on the Red Birdo, and I came up with this:I suck at coding.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
Oops! forgot the end again!