tModLoader Help with an item

Bean_Lord

Terrarian
I'm making an item that hurts the player upon consumption,
1659564721887.png

but i got this error message.
1659564800907.png

How do I fix it.
 

Attachments

  • 1659564880168.png
    1659564880168.png
    3.2 KB · Views: 42
Alrighty, two issues here, first off the red lines are caused because cooldownCounter doesn't exist, it's you don't need to assign anything to it, you're just passing the value -1 into the function, so you can just put -1.
Secondly, the Function ByPlayer requires the index of the player killing to be passed into it, the variable for this is Player,whoAmI

Modified code:
player.Hurt(PlayerDeathReason.ByPlayer(player.whoAmI), 20, 1, false, false, false, -1);

Side note, the last 4 passed variables are the same as the default assignments so you can ignore them, the code comes out as:
player.Hurt(PlayerDeathReason.ByPlayer(player.whoAmI), 20, 1);

Hope this helps, -K
 
So Visual Studio came up with the same error message except it says PlayerDeathReason doesn't exist in the current context.
 
Back
Top Bottom