Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- r/themoddingofisaac
- Error when having multiple familiars orbiting around the player
- u/quotee
- This code works fine, but when I look in the log I get this error:
- mirrorshield.lua:41: bad argument #1 to 'AddToOrbit' (EntityFamiliar expected, got number)
- The problem starts to occur when I have more than one mirror shield at a time. Every one of them stacks on top of one another.
- local mod = RegisterMod("Mirror Shield", 1)
- local COLLECTIBLE_MIRROR_SHIELD = Isaac.GetItemIdByName("Mirror Shield")
- local debug = true
- local itemProperties = {
- VARIANT = Isaac.GetEntityVariantByName("Mirror Shield"),
- ORBIT_DISTANCE = Vector (65, 65), -- Distance orbital is from the player
- ORBIT_SPEED = 0.02, -- 0 < orbitSpeed < .1
- ORBIT_LAYER = 200
- }
- function mod:onRunInitialization()
- if Game():GetFrameCount() == 0 then
- if debug then
- Isaac.ExecuteCommand("spawn 5.100."..COLLECTIBLE_MIRROR_SHIELD)
- end
- end
- end
- mod:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, mod.onRunInitialization)
- function mod:init(shield)
- shield:AddToOrbit(itemProperties.ORBIT_LAYER)
- end
- mod:AddCallback(ModCallbacks.MC_FAMILIAR_INIT, mod.init, itemProperties.VARIANT)
- function mod:onUpdate(shield)
- local player = Isaac.GetPlayer(0)
- shield.OrbitDistance = itemProperties.ORBIT_DISTANCE
- shield.OrbitSpeed = itemProperties.ORBIT_SPEED
- shield.Velocity = shield:GetOrbitPosition(player.Position + player.Velocity) - shield.Position
- end
- mod:AddCallback(ModCallbacks.MC_FAMILIAR_UPDATE, mod.onUpdate, itemProperties.VARIANT)
- function mod:updateCache(player, cacheFlag)
- if cacheFlag == CacheFlag.CACHE_FAMILIARS then
- local shield_pickups = player:GetCollectibleNum(COLLECTIBLE_MIRROR_SHIELD)
- local shield_rng = player:GetCollectibleRNG(COLLECTIBLE_MIRROR_SHIELD)
- player:CheckFamiliar(itemProperties.VARIANT, shield_pickups, shield_rng)
- end
- end
- mod:AddCallback(ModCallbacks.MC_EVALUATE_CACHE, mod.updateCache)
- ShareComment2
- Best
- Write a comment
- Share this Link
- Preparing your link
- SHARE LINK
Advertisement
Add Comment
Please, Sign In to add comment