Freeslotting sprites doesn't work inside of functions.

Status
Not open for further replies.

Prisima

Member
If you freeslot a sprite inside of a function, like this:
Code:
addHook("ThinkFrame", do
	if not _G["SPR_ABC1"]
		freeslot("SPR_ABC1")
	end
	for p in players.iterate
		if _G["SPR_ABC1"]
			p.mo.sprite = SPR_ABC1
		end
	end
end)
you get an error (in addition to the sprite not being displayed):
Code:
ERROR: R_ProjectSprite: invalid sprite frame 0/0 for ABC1
But if you freeslot the sprite outside of the function, like this:
Code:
freeslot("SPR_ABC1")

addHook("ThinkFrame", do
	for p in players.iterate
		p.mo.sprite = SPR_ABC1
	end
end)
everything is fine, the sprite displays, and no errors occur.
 
Last edited by a moderator:
This is because the sprite prefix doesn't exist when the WAD containing the sprites is loaded (I assume they're in the same WAD as the script here), so the game never thinks to load the lumps with the sprite prefix at all. Freeslotting the sprite after the game has already loaded the WAD won't cause the game to look again in it for sprite lumps.

Probably got some details wrong but it's really because the freeslotting doesn't take place on WAD load.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top