How can I embiggen (walktall) all copies of my NPCs?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

How can I embiggen (walktall) all copies of my NPCs?

Post by sheamkennedy »

I currently have this embiggenment script which allows all my NPCs to appear as a larger sprite:

Code: Select all

script, embiggen NPcs, begin
  variable(npc, sl) 
  for(npc, 0, 29) do(
    if(get NPC id(npc) >= 0) then(
	  # Checks if NPC exists
	  sl := get NPC slice(npc)
	  embiggen walkabout slice(sl)
    )
  )
end
How can I enhance this code to also embiggen all copies of each of these NPCs? I currently have an NPC which acts as a collectable coin and I'd like to place about 30 of them on a map without making 30 separate NPCs. I also figure I'll have copies of other NPCs in the future. I assume this can be somehow done with a nested for-loop.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Hmm, that's different from the the script that's posted on the wiki, which embiggens all NPCs on the map.

But if you want to only embiggen NPCs with certain ID numbers, use "NPC copy count" and "NPC reference":

Code: Select all

script, embiggen NPcs, begin
  variable(npc, sl, idx)
  for(npc, 0, 29) do(
    for(idx, 0, NPC copy count(npc) -- 1) do (
      sl := get NPC slice(NPC reference(npc, idx))
      embiggen walkabout slice(sl)
    )
  )
end
By the way, that was a strange use of "get npc id"... I had to look it up to confirm it would work.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Thanks I'll give your script a try soon.
TMC wrote:By the way, that was a strange use of "get npc id"... I had to look it up to confirm it would work.
Haha that's exactly how it appears in the wiki actually. I just was showing the NPC walktall portion of the full walktall code as my question only pertained to NPCs.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Actually, the version on the wiki passes an NPC reference (a negative number) to "get NPC ID", while you were passing an NPC ID, which is pretty circular. However, almost all script commands accept either IDs or references.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Oh I see the difference now. What probably happened was I made my script myself while using the walktall script as a reference. I didn't understand the code the way it was on the wiki so I wrote it in a way that made sense to me.

Perhaps now that I understand this more I should switch to the wiki code as it looks like it will save me from having to specify the amount of NPCs on a map.

EDIT: Oh actually it looks like it already embiggens copies haha. Got it. Works nicely too. Thanks.
Last edited by sheamkennedy on Sat Mar 26, 2016 7:56 pm, edited 1 time in total.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Post Reply