Lua Help: Displaying Sprites

Status
Not open for further replies.

Larz T

Member
So I had made a new object with Lua and I know what I am doing so far but I'm having one major issue, I can't seem to get the desired sprites to show up. I had been at it for at least six hours as of yesterday. My one friend suggested that I should put all the frames of the sprites in the freeslot (ex. SPR_SINGA, SPR_SINGB and so on).

I am completely stumped on what I should do. I'm leaving the code here so anybody can view alongside the lump names for the sprites. Thank you in advance. Also please DO NOT quote the Spoilers if you reply. Just trying to keep this thread neat as possible. Also I forgot to mention that sfx_fre002 is in the source wad that I'm adding in conjunction with this script.

Code:
freeslot ("MT_SUPERRINGRING", "SPR_SINGA", "SPR_SINGB", "SPR_SINGC", "SPR_SINGD", "SPR_SINGE", "SPR_SINGF", "SPR_SINGH", "SPR_SINGI",
"SPR_SINGJ", "SPR_SINGK", "SPR_SINGL", "SPR_SINGM", "SPR_SINGN", "SPR_SINGO", "SPR_SINGP", "SPR_SINGQ", "SPR_SINGR", "SPR_SINGS",
"SPR_SINGT", "SPR_SINGU", "SPR_SINGV", "SPR_SINGW", "SPR_SINGX", "S_SING1", "S_SING2", "S_SING3", "S_SING4", "S_SING5", "S_SING6", 
"S_SING7", "S_SING8", "S_SING9", "S_SING10", "S_SING11", "S_SING12", "S_SING13", "S_SING14", "S_SING15", "S_SING16", "S_SING17", 
"S_SING18", "S_SING19", "S_SING20", "S_SING21", "S_SING22", "S_SING23", "S_SING24")

mobjinfo[MT_SUPERRINGRING] = {
	doomednum = 324,
	spawnstate = S_SING1,
	spawnhealth = 1000,
	deathsound = sfx_fre005,
	reactiontime = MT_FLINGRING,
	speed = 3932160,
	radius = 16*FRACUNIT,
	height = 24*FRACUNIT,
	mass = 100,
	flags = MF_SPECIAL|MF_NOGRAVITY|MF_SLIDEME,
}
states[S_SING1] = {
	sprite = SPR_SING,
	frame = A,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING2,
}
states[S_SING2] = {
	sprite = SPR_SING,
	frame = B,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING3
}
states[S_SING3] = {
	sprite = SPR_SING,
	frame = C,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING4
}
states[S_SING4] = {
	sprite = SPR_SING,
	frame = D,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING5
}
states[S_SING5] = {
	sprite = SPR_SING,
	frame = E,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING6
}
states[S_SING6] = {
	sprite = SPR_SING,
	frame = F,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING7
}
states[S_SING7] = {
	sprite = SPR_SING,
	frame = G,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING8
}
states[S_SING8] = {
	sprite = SPR_SING,
	frame = H,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING9
}
states[S_SING9] = {
	sprite = SPR_SING,
	frame = I,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING10
}
states[S_SING10] = {
	sprite = SPR_SING,
	frame = J,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING11
}
states[S_SING11] = {
	sprite = SPR_SING,
	frame = K,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING12
}
states[S_SING12] = {
	sprite = SPR_SING,
	frame = L,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING13
}
states[S_SING13] = {
	sprite = SPR_SING,
	frame = M,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING14
}
states[S_SING14] = {
	sprite = SPR_SING,
	frame = N,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING15
}
states[S_SING15] = {
	sprite = SPR_SING,
	frame = O,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING16
}
states[S_SING16] = {
	sprite = SPR_SING,
	frame = P,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING17
}
states[S_SING17] = {
	sprite = SPR_SING,
	frame = Q,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING18
}
states[S_SING18] = {
	sprite = SPR_SING,
	frame = R,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING19
}
states[S_SING19] = {
	sprite = SPR_SING,
	frame = S,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING20
}
states[S_SING20] = {
	sprite = SPR_SING,
	frame = T,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING21
}
states[S_SING21] = {
	sprite = SPR_SING,
	frame = U,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING22
}
states[S_SING22] = {
	sprite = SPR_SING,
	frame = V,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING23
}
states[S_SING23] = {
	sprite = SPR_SING,
	frame = W,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING24
}
states[S_SING24] = {
	sprite = SPR_SING,
	frame = X,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING1
}

8pB9i.png
 
Last edited:
firstly, why aren't you doing this as SOC? Coding simple objects with Lua souns weird, aside of that, do not add SPR_ next to the sprite in the states, pretty sure it's your problem.

EDIT: Example:

Code:
states[S_SING1] = {
	sprite = [B]SING[/B],
	frame = A,
	tics = 1,
	action = A_AttractChase,
	var1 = 0,
	var2 = 0,
	nextstate = S_SING2,
}
 
Try this instead
freeslot(
"MT_SUPERRINGRING",
"SPR_SING",
"S_SING1",
"S_SING2",
"S_SING3",
"S_SING4",
"S_SING5",
"S_SING6",
"S_SING7",
"S_SING8",
"S_SING9",
"S_SING10",
"S_SING11",
"S_SING12",
"S_SING13",
"S_SING14",
"S_SING15",
"S_SING16",
"S_SING17",
"S_SING18",
"S_SING19",
"S_SING20",
"S_SING21",
"S_SING22",
"S_SING23",
"S_SING24")

mobjinfo[MT_SUPERRINGRING] = {
doomednum = 324,
spawnstate = S_SING1,
spawnhealth = 1000,
deathsound = sfx_fre005,
reactiontime = MT_FLINGRING,
speed = 3932160,
radius = 16*FRACUNIT,
height = 24*FRACUNIT,
mass = 100,
flags = MF_SPECIAL|MF_NOGRAVITY|MF_SLIDEME,
}
states[S_SING1] = {
sprite = SPR_SING,
spriteframe = A,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING2,
}
states[S_SING2] = {
sprite = SPR_SING,
spriteframe = B,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING3
}
states[S_SING3] = {
sprite = SPR_SING,
spriteframe = C,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING4
}
states[S_SING4] = {
sprite = SPR_SING,
spriteframe = D,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING5
}
states[S_SING5] = {
sprite = SPR_SING,
spriteframe = E,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING6
}
states[S_SING6] = {
sprite = SPR_SING,
spriteframe = F,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING7
}
states[S_SING7] = {
sprite = SPR_SING,
spriteframe = G,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING8
}
states[S_SING8] = {
sprite = SPR_SING,
spriteframe = H,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING9
}
states[S_SING9] = {
sprite = SPR_SING,
spriteframe = I,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING10
}
states[S_SING10] = {
sprite = SPR_SING,
spriteframe = J,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING11
}
states[S_SING11] = {
sprite = SPR_SING,
spriteframe = K,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING12
}
states[S_SING12] = {
sprite = SPR_SING,
spriteframe = L,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING13
}
states[S_SING13] = {
sprite = SPR_SING,
spriteframe = M,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING14
}
states[S_SING14] = {
sprite = SPR_SING,
spriteframe = N,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING15
}
states[S_SING15] = {
sprite = SPR_SING,
spriteframe = O,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING16
}
states[S_SING16] = {
sprite = SPR_SING,
spriteframe = P,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING17
}
states[S_SING17] = {
sprite = SPR_SING,
spriteframe = Q,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING18
}
states[S_SING18] = {
sprite = SPR_SING,
spriteframe = R,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING19
}
states[S_SING19] = {
sprite = SPR_SING,
spriteframe = S,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING20
}
states[S_SING20] = {
sprite = SPR_SING,
spriteframe = T,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING21
}
states[S_SING21] = {
sprite = SPR_SING,
spriteframe = U,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING22
}
states[S_SING22] = {
sprite = SPR_SING,
spriteframe = V,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING23
}
states[S_SING23] = {
sprite = SPR_SING,
spriteframe = W,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING24
}
states[S_SING24] = {
sprite = SPR_SING,
spriteframe = X,
tics = 1,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING1
}
This worked for me, so...

firstly, why aren't you doing this as SOC? Coding simple objects with Lua souns weird, aside of that, do not add SPR_ next to the sprite in the states, pretty sure it's your problem.

No, the SPR_ should be there, in fact, you add them even when you are coding with SOC
 
Last edited:
Thanks HellHawk! I feel so relieved. The ring isn't spinning for some reason but I'm pretty sure that can easily be fixed by myself.
 
So in GIMP, I had added the sprites and animated it. Each frame is at 100 milliseconds and 100 milliseconds is 0.1 seconds. So would SRB2 take 3.5 as a variable for tics?

Also it should look like this if done correctly:
8pLku.gif
 
Last edited:
No, you can not use 3.5 as a variable for tics. Tics are pretty much how the game runs, things get executed one tic at a time. Therefor there is nothing in-between them.
 
I still can't get the object to animate. Is it something I am doing with the code?
Code:
states[S_SING1] = {
sprite = SPR_SING,
spriteframe = A,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING2,
}
states[S_SING2] = {
sprite = SPR_SING,
spriteframe = B,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING3
}
states[S_SING3] = {
sprite = SPR_SING,
spriteframe = C,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING4
}
states[S_SING4] = {
sprite = SPR_SING,
spriteframe = D,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING5
}
states[S_SING5] = {
sprite = SPR_SING,
spriteframe = E,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING6
}
states[S_SING6] = {
sprite = SPR_SING,
spriteframe = F,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING7
}
states[S_SING7] = {
sprite = SPR_SING,
spriteframe = G,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING8
}
states[S_SING8] = {
sprite = SPR_SING,
spriteframe = H,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING9
}
states[S_SING9] = {
sprite = SPR_SING,
spriteframe = I,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING10
}
states[S_SING10] = {
sprite = SPR_SING,
spriteframe = J,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING11
}
states[S_SING11] = {
sprite = SPR_SING,
spriteframe = K,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING12
}
states[S_SING12] = {
sprite = SPR_SING,
spriteframe = L,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING13
}
states[S_SING13] = {
sprite = SPR_SING,
spriteframe = M,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING14
}
states[S_SING14] = {
sprite = SPR_SING,
spriteframe = N,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING15
}
states[S_SING15] = {
sprite = SPR_SING,
spriteframe = O,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING16
}
states[S_SING16] = {
sprite = SPR_SING,
spriteframe = P,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING17
}
states[S_SING17] = {
sprite = SPR_SING,
spriteframe = Q,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING18
}
states[S_SING18] = {
sprite = SPR_SING,
spriteframe = R,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING19
}
states[S_SING19] = {
sprite = SPR_SING,
spriteframe = S,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING20
}
states[S_SING20] = {
sprite = SPR_SING,
spriteframe = T,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING21
}
states[S_SING21] = {
sprite = SPR_SING,
spriteframe = U,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING22
}
states[S_SING22] = {
sprite = SPR_SING,
spriteframe = V,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING23
}
states[S_SING23] = {
sprite = SPR_SING,
spriteframe = W,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING24
}
states[S_SING24] = {
sprite = SPR_SING,
spriteframe = X,
tics = 4,
action = A_AttractChase,
var1 = 0,
var2 = 0,
nextstate = S_SING1
}
 
Status
Not open for further replies.

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

Back
Top