Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ArunesMod = RegisterMod("Arunes", 1)
- local game = Game()
- --Stats--
- local ArunesStats = {
- Arunes1 = 10
- }
- local Dir = {
- [Direction.UP] = Vector(0,-1),
- [Direction.DOWN] = Vector(0,1),
- [Direction.LEFT] = Vector(-1,0),
- [Direction.RIGHT] = Vector(1,0)
- }
- local Arunes_item = Isaac.GetItemIdByName("Arunes")
- local Costume_Anim = Isaac.GetCostumeIdByPath("gfx/characters/arunesanim.anm2")
- EffectVariant.ARUNES_COSTUME = Isaac.GetEntityVariantByName("Arunes Body")
- function ArunesMod:onUpdate(player)
- local MoveDir = player:GetMovementDirection()
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities.Type == EntityType.ENTITY_EFFECT
- and entities.Variant == EffectVariant.ARUNES_COSTUME then
- local costumeEffect = entities
- local sprite = costumeEffect:GetSprite()
- -- set the offset
- effect.Velocity = player.Position - effect.Position
- -- check the fire direction to set the offset
- if MoveDir == Direction.DOWN then
- if not (sprite:IsPlaying(“WalkDown“) then
- sprite:Play(“WalkDown“, true)
- end
- elseif MoveDir == Direction.RIGHT then
- if not (sprite:IsPlaying(“WalkRight“) then
- sprite:Play(“WalkRight“, true)
- end
- elseif MoveDir == Direction.UP then
- if not (sprite:IsPlaying(“WalkUp“) then
- sprite:Play(“WalkUp“, true)
- end
- elseif MoveDir == Direction.LEFT then
- if not (sprite:IsPlaying(“WalkLeft“) then
- sprite:Play(“WalkLeft“, true)
- end
- else
- sprite:Play(“WalkDown“, true)
- end
- end
- end
- end
- ArunesMod:AddCallback( ModCallbacks.MC_POST_PLAYER_UPDATE, ArunesMod.onUpdate)
- --When effect updates + costume for item--
- --Cache Updates for stats--
- function ArunesMod:cacheUpdate(player, cacheFlag)
- player = Isaac.GetPlayer(0)
- --costume finally
- if player:HasCollectible(Arunes_item) then
- if HasArunes ~= true then
- player:AddNullCostume(Costume_Anim)
- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.ARUNES_COSTUME, 0, player.Position, Vector(0,0), player):ToEffect()
- HasArunes = true
- end
- elseif HasArunes == true and player:HasCollectible(Arunes_item) == false then
- player:TryRemoveNullCostume(Costume_Anim)
- HasArunes = false
- end
- --
- --stats update
- if cacheFlag == CacheFlag.CACHE_LUCK then
- if player:HasCollectible(Arunes_item) then
- player.Luck = player.Luck + ArunesStats.Arunes1
- end
- end
- if cacheFlag == CacheFlag.CACHE_FLYING then
- if player:HasCollectible(Arunes_item) then
- player.CanFly = true
- end
- end
- end
- ArunesMod:AddCallback( ModCallbacks.MC_EVALUATE_CACHE, ArunesMod.cacheUpdate)
- function ArunesMod:onCostume(effect)
- local sprite = effect:GetSprite()
- local player = Isaac.GetPlayer(0)
- local MoveDir = player:GetMovementDirection()
- effect.RenderZOffset = 4900 -- 1300 is enough for most obstacles, but not for the player
- effect.Velocity = player.Position - effect.Position
- if effect:GetData().Init == nil then
- -- Isaac.ConsoleOutput("Appear ")
- -- play the correct animation
- if MoveDir == Direction.DOWN then
- sprite:Play(“WalkDown“, true)
- elseif MoveDir == Direction.RIGHT then
- sprite:Play(“WalkRight“, true)
- elseif MoveDir == Direction.UP then
- sprite:Play(“WalkUp“, true)
- elseif MoveDir == Direction.LEFT then
- sprite:Play(“WalkLeft“, true)
- else
- sprite:Play(“WalkDown“, true)
- end
- effect:GetData().Init = true
- end
- end
- ArunesMod:AddCallback(ModCallbacks.MC_POST_EFFECT_INIT, ArunesMod.onCostume, EffectVariant.ARUNES_COSTUME)
- function ArunesMod.onNewRoom(_)
- local player = Isaac.GetPlayer(0)
- local roomType = game:GetRoom():GetType()
- -- give the costume to the player
- if player:HasCollectible(Arunes_item) then
- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.ARUNES_COSTUME, 0, player.Position, Vector(0,0), player):ToEffect()
- end
- end
- ArunesMod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, ArunesMod.onNewRoom)
Advertisement
Add Comment
Please, Sign In to add comment