Get Sprite Palette

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

Moderators: marionline, SDHawk

Post Reply
User avatar
Soule X
Red Slime
Posts: 86
Joined: Wed Sep 19, 2012 4:18 pm
Location: Indianapolis

Get Sprite Palette

Post by Soule X »

I don't know if this is a question or a statement or just a rant, but I noticed when you use the Get Sprite Palette command on a sprite with a default palette it returns -1, which is correct, I know. I feel like it would be useful in certain circumstances if it returned the actual palette instead. If I'm adjusting palettes by increments it doesn't really work. Say the default palette is 5 and I want to bump it up to 6 so I add one. Well now it's going to be 0 instead.

In a weird way I feel like it should work both ways.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Use the get sprite default pal command.
User avatar
Soule X
Red Slime
Posts: 86
Joined: Wed Sep 19, 2012 4:18 pm
Location: Indianapolis

Post by Soule X »

Ah. Okay I didn't see that one. That works. It's an extra step but still kind of what I was looking for. I actually went back after I posted and changed the load command to load the actual palette number, but it's good to know for the future.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

A little wrapper script could make this a lot more convenient to work with:

Code: Select all

script, get current sprite pal, handle, begin
  variable(result)
  result := get sprite palette(handle)
  if(result == -1) then(
    result := get sprite default palette(handle)
  )
  exit returning(result)
end
User avatar
Soule X
Red Slime
Posts: 86
Joined: Wed Sep 19, 2012 4:18 pm
Location: Indianapolis

Post by Soule X »

Yes that's exactly what I was looking for. I might not need it again for this project but I'm sure it would come in handy for some games. Maybe consider adding a hard-coded function like Get True Palette or something. I'm not sure if it's usefulness is broad enough to warrant that.
Post Reply