I need an if function that can check if a certain npc has the palette id of 2.
I tried using read npc, but it never properly returns as true.
How to check the palette of an npc
Moderators: marionline, SDHawk
- Seamus Moore
- Slime
- Posts: 19
- Joined: Mon Mar 16, 2020 9:39 pm
- Location: Seamus Moore's House
How to check the palette of an npc
dQw4w9WgXcQ
There must be a critical typo in your code!
Look, this line should do it.
Look, this line should do it.
Code: Select all
if (read NPC (9,NPCstat:palette) == 2) then (...) else (...)
- Bob the Hamster
- Lord of the Slimes
- Posts: 7684
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
Yes, Bird's approach is correct.
One caveat is that it won't help if your NPCs are using the default palette -1
If that is the case, then "read NPC" will just return -1 instead of reporting whatever default palette is actually being used.
Here is a slice-based workaround that solves that situation
Add this script to your script file:
then you can use it like this:
One caveat is that it won't help if your NPCs are using the default palette -1
If that is the case, then "read NPC" will just return -1 instead of reporting whatever default palette is actually being used.
Here is a slice-based workaround that solves that situation
Add this script to your script file:
Code: Select all
script, check npc palette, npc, begin
variable(sl, pal)
sl := get npc sprite(npc)
pal := get sprite palette(sl)
if(pal == -1) then(
pal := get sprite default pal(sl)
)
exit returning(pal)
end
Code: Select all
if (check npc palette (9) == 2) then (...) else (...)