Lua Object help (Skid object)

Status
Not open for further replies.
I'm just experimenting with Lua for my own personal pleasure and I'm trying to get this to work:

Code:
addHook("ThinkFrame", do
 for player in players.iterate
  if P_IsObjectOnGround(player.mo, player.mo) // If the player is on the ground...
  and not player.mo.state==S_PLAY_STND // And not standing...
  and not player.mo.state>=S_PLAY_TAP1 // And not idling...
  and not player.mo.state>=S_PLAY_TEETER1 // And not teetering on an edge...
   P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_SMOKE) // Spawn a smoke object.
  end
 end
end)

But MT_SMOKE doesn't work. I've tried MT_SMOK and MT_SMOKE, but neither work. They don't spawn at all. They only spawn in the first frame that I move, then never spawn ever again.
 
"and not player.mo.state>=S_PLAY_TAP1" excludes all states above S_PLAY_TAP1. However, all player states besides S_PLAY_STND (which you have excluded separately) are above S_PLAY_TAP1, so your condition is never true. If you want to exclude the idling states, you have you check if the state is between S_PLAY_TAP1 and S_PLAY_TAP2, not just if it's above S_PLAY_TAP1. Same with the teetering states, you have to check if the state is between S_PLAY_TEETER1 and S_PLAY_TEETER2.

Code:
addHook("ThinkFrame", do
 for player in players.iterate
  if P_IsObjectOnGround(player.mo, player.mo) // If the player is on the ground...
  and not player.mo.state==S_PLAY_STND // And not standing...
  and not (player.mo.state>=S_PLAY_TAP1 and player.mo.state<=S_PLAY_TAP2) // And not idling...
  and not (player.mo.state>=S_PLAY_TEETER1 and player.mo.state<=S_PLAY_TEETER2) // And not teetering on an edge...
   P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_SMOKE) // Spawn a smoke object.
  end
 end
end)
This should work (unless I missed some other error in the script).
 
I tested your code, but it acts exactly like mine. The first frame I move, the smoke spawns, but never again.

EDIT: I just tested it with MT_SUPERSPARK with your code in the case that MT_SMOKE has some odd property, but it still spawns smoke for a frame? The heck? There's not any smoke in the code, even.

To clarify, I want smoke to spawn when the player is on the ground and is not standing, idling, or teetering on an edge (just for experimentation to get a better hang of Lua).

Got it working thanks to Monster Iestyn. Code for anyone interested (no practical use really, but hey):

Code:
addHook("ThinkFrame", do
 for player in players.iterate
  if P_IsObjectOnGround(player.mo) and player.panim != PA_IDLE
   P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z, MT_PARTICLE) // Spawn a smoke object.
  end
 end
end)
 
Last edited:
Status
Not open for further replies.

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

Back
Top