[zscript] Changing psprite frame

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
User avatar
zrrion the insect
Posts: 2410
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

[zscript] Changing psprite frame

Post by zrrion the insect »

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.
User avatar
krokots
Posts: 257
Joined: Tue Jan 19, 2010 5:07 pm

Re: [zscript] Changing psprite frame

Post by krokots »

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
User avatar
zrrion the insect
Posts: 2410
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

Re: [zscript] Changing psprite frame

Post by zrrion the insect »

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?
User avatar
Gutawer
Posts: 466
Joined: Sat Apr 16, 2016 6:01 am
Preferred Pronouns: She/Her

Re: [zscript] Changing psprite frame

Post by Gutawer »

Instead of doing players[consoleplayer].psprites, you should do player.findPSprite(<LAYER>) (I'm assuming you're calling this from a PlayerPawn actor).
User avatar
Xaser
 
 
Posts: 10772
Joined: Sun Jul 20, 2003 12:15 pm

Re: [zscript] Changing psprite frame

Post by Xaser »

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. :P

Return to “Scripting”