Problem with Lua scripting

Status
Not open for further replies.

Simon_T

Pyro the Setsuna Fan
I'm trying to make an Whirlwind Shield-like second ability for an Super Tails character WAD (it's a private project), but I don't know how to use the P_DoJumpShield function (idk what is "player_t")

This is my example code, what I'm doing wrong? :'V

Code:
addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "testchar"
			if player.cmd.buttons & BT_USE
			and (player.pflags & PF_JUMPED)
			and not player.exiting
				P_DoJumpShield(player.mo)
			end
		end
	end
end)
 
You probably want to use "player" instead of "player.mo" in the P_DoJumpShield function, as the former is player_t and the latter is mobj_t.

If you want an explanation of why you do the above, player_t and mobj_t etc just refer to the types of userdata you're dealing with. Because your "player" variable comes from the "for player in players.iterate" line, that means "player" is assigned a player_t userdata value, which means it represents data for a player. "player.mo" meanwhile gets the player's corresponding Object, which has the mobj_t userdata type (mobj = map object).

Some day I need to sort out making a tutorial to clear up this kind of confusion once and for all, bleh. x_x
 
Last edited:
Status
Not open for further replies.

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

Back
Top