ability change using lua not working

Jammin'

NNNO WAY! I CAN'T BELIEEEEVE THIS!
i mean, i dont know much about lua and i can barely write working code without help. i mean no warnings come up when i load the lua, but yet the abilities dont change.
code:
Code:
addHook("PlayerThink", function(player)
  if player.mo.skin == "sonic" then
    player.mo.charability = CA_DOUBLEJUMP
  end
  if player.mo.skin == "tails" then
    player.mo.charability = CA_FLOAT
  end
  if player.mo.skin == "metalsonic" then
    player.mo.charability = CA_SWIM
    player.mo.pflags = $ | SF_NOJUMPSPIN | SF_STOMPDAMAGE
  end
end)
 
Last edited:
When pasting your code, please:
  • Indent your code
  • Make sure it is in between [CODE][/CODE] tags

That said, your code seems about right, however the problem resides in that objects do not have a charability variable - Only players do.
Instead of player.mo.charability, use player.charability.
On top of that, objects don't have pflags either. You know what to do ;)
 
sure wish the wiki told you more. :/ but thanks anyway.

edit:
how do i remove flags on a character? when i use metal, he just swims for a few seconds before just floating back down. even when i try and swim more. how do i remove the "multiability" flag when i load the script?
 
Last edited:
sure wish the wiki told you more. :/ but thanks anyway.
What do you mean? If you're talking about what variables are where, the wiki already tells you that players use the player_t structure and objects use the mobj_t structure.

how do i remove flags on a character? [...] how do i remove the "multiability" flag [...]
If you're talking about skin flags, which are not object flags nor player flags, you would do something like
player.charflags = $ & ~SF_MULTIABILITY.

That said, keep in mind that only player flags go in pflags and only skin flags go in charflags.
That is, flags that start with SF_ are skin flags and not player flags. Player flags would be the PF_ ones.
 
I'm not psychic.

You need to show the whole error message, as well as the portion of the code that throws the error.
Just saying that your code throws an error, then only showing a part of it and knowing that you have modified the code does not allow for troubleshooting.


Refer to the following example about how to read error messages and find out what is causing it:
ULJhTUF.png
 
Last edited:
i know this is a different topic but how do i set a freeslot as the followitem through lua? i THINK i got the freeslot down. but i cant seem to change the followitem in lua.
 
A player's followitem is stored in player.followitem, therefore if you set it to something else, you change the player's followitem.
 
i tried that. it doesnt show up. i also put the free slot in SOC_PLAY and yes. i did look at the wiki about freeslots.
 
Last edited:
freeslot:
Code:
Freeslot
MT_HOGHEAD
S_HEDGEHOGHEAD
SPR_HEDG

lua:
Code:
addHook("PlayerThink", function(player)
  if player.mo.skin == "notspoilingcharactername" then
    if (player.cmd.buttons & BT_CUSTOM3) then
	   player.followitem = MT_HOGHEAD
	end
  end
end)
 
well, how do i do that? nevermind. found a wiki page on that.

edit:
is there a flag i would use for a followitem?

---------- Post added at 03:11 PM ---------- Previous post was at 01:31 PM ----------

how do i make something toggle in lua?
 
Last edited:

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

Back
Top