Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("yourMod", 1)
- local game = Game()
- TrinketType.TRINKET_YOUR_TRINKET = Isaac.GetTrinketIdByName("Your Trinket") -- trinket
- Mod.COSTUME_ONE = Isaac.GetCostumeIdByPath("gfx/characters/YourCostume.anm2")
- Mod.COSTUME_TWO = Isaac.GetCostumeIdByPath("gfx/characters/YourCostumeTwo.anm2")
- Mod.COSTUME_THREE = Isaac.GetCostumeIdByPath("gfx/characters/YourCostumeThree.anm2")
- Mod.COSTUME_FOUR = Isaac.GetCostumeIdByPath("gfx/characters/YourCostumeFour.anm2")
- Mod.COSTUME_FIVE = Isaac.GetCostumeIdByPath("gfx/characters/yourCostumeFive.anm2")
- -- on post peffect update
- function Mod:onModUpdate(player)
- if game:GetFrameCount() == 1
- and ctc then
- ctc:RegisterTrinketCostume(TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_ONE, "true")
- ctc:AddMoreCostumes(TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_TWO, Mod.COSTUME_THREE, Mod.COSTUME_FOUR, Mod.COSTUME_FIVE)
- -- ctc:AddMoreCostumes(TrinketType.TRINKET_YOUR_TRINKET, Mod.COSTUME_TWO, Mod.COSTUME_THREE, _, _)
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onModUpdate)
- -- for the sake of this example mod, let's say we make a trinket, which changes the player's appearance depending on the amount of time the player got hit
- -- Max is 4 times per floor. At the start of a new floor the 'hit'-counter ans the player's appearance gets reset.
- -- every condition has one costume asssigned to it
- -- Our list of conditiond looks like this
- -- Condition 1 = No damage taken | costume 1
- -- Condition 2 = 1 damage taken | costume 2
- -- Condition 3 = 2 damage taken | costume 3
- -- Condition 4 = 3 damage taken | costume 4
- -- Condition 5 = 4 damage taken | costume 5
- function Mod:conditionExample(entity, amt, flag, source, countdown)
- if ctc then -- check if the Trinket Costume mod is active
- for i = 0, (game:GetNumPlayers() - 1) do
- local player = Isaac.GetPlayer(i)
- local playerData = player:GetData()
- if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) then
- if playerData.GotHit == nil then -- init playerData
- playerData.GotHit = 0
- -- during the first init of the mod the first condition is automatically set to 'true'
- -- no condition change during the init needed
- end
- if playerData.GotHit == 0 then -- player never got hit before
- playerData.GotHit = 1 -- now he got hit once
- -- change the condition
- -- required function ctc:UpdateConditions(player, trinketId, conditionNum)
- -- will set the other conditions to 'false' and remove the current costume
- -- trinketId = TrinketType.TRINKET_YOUR_TRINKET
- -- conditionNum is the number of the your condition which is now fullfilled
- ctc:UpdateConditions(player, TrinketType.TRINKET_YOUR_TRINKET, 2)
- elseif playerData.GotHit == 1 then -- player got hit once before
- playerData.GotHit = 2 -
- ctc:UpdateConditions(player, TrinketType.TRINKET_YOUR_TRINKET, 3)
- elseif playerData.GotHit == 2 then -- player got hit once before
- playerData.GotHit = 3
- ctc:UpdateConditions(player, TrinketType.TRINKET_YOUR_TRIKET, 4)
- elseif playerData.GotHit == 3 then -- player got hit once before
- playerData.GotHit = 4
- ctc:UpdateConditions(player, TrinketType.TRINKET_YOUR_TRINKET, 5)
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.conditionExample, EntityType.ENTITY_PLAYER)
- -- So now to the part where we check if the player entered a new level/floor
- function Mod:conditionExamplePartTwo(_)
- if ctc then -- check if the Trinket Costume mod is active
- -- now we need to check for the player, since he isn't given by the Callback itself
- for i = 0, (game:GetNumPlayers() - 1) do
- local player = Isaac.GetPlayer(i)
- local playerData = player:GetData()
- -- check if the player has your trinket
- if player:HasTrinket(TrinketType.TRINKET_YOUR_TRINKET) then
- if playerData.GotHit > 0 then -- the player got hit on the previous floor, so has another costume
- playerData.GotHit = 0 -- reset the 'hit'- counter
- -- change the condition
- ctc:UpdateConditions(player, TrinketType.TRINKET_YOUR_TRINKET, 1) -- never gotten hit was the first conditions
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, Mod.conditionExamplePartTwo)
Advertisement
Add Comment
Please, Sign In to add comment