[zscript] Changing psprite frame
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 2410
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
[zscript] Changing psprite frame
How would I set the frame of a given psprite layer. I recall someone posting a similar question in an older zscript thread but I have been unable to find it.
-
- Posts: 257
- Joined: Tue Jan 19, 2010 5:07 pm
Re: [zscript] Changing psprite frame
You mean something like this ?
Code: Select all
let psp = Players[consoleplayer].psprites; //Get the player PSprite
psp.frame = someInteger; //Set the current PSprite frame to some other int
-
- Posts: 2410
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: [zscript] Changing psprite frame
That is exactly it! Thank you. That code will be unbelievable helpful in getting rid of some of the more egregious decorate-isms lingering in my code.
EDIT: How would I specify the psprite layer?
EDIT: How would I specify the psprite layer?
-
- Posts: 466
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: [zscript] Changing psprite frame
Instead of doing players[consoleplayer].psprites, you should do player.findPSprite(<LAYER>) (I'm assuming you're calling this from a PlayerPawn actor).
-
-
- Posts: 10772
- Joined: Sun Jul 20, 2003 12:15 pm
Re: [zscript] Changing psprite frame
I wrote a general function for this (multiplayer-safe) for Eriguns: here it be, 'cause GitHub is mighty handy. Feel free to yoink it, 'cause the MIT license is similarly handy. 
