BwLua / Events 2.txt
Yourmom123's picture
Upload 6 files
758cb70 verified
-- events
-- ProjectileLaunched
Parameters
shooter: Entity | nil
The entity that launched the projectile (may not exist).
projectileType: ProjectileType
The type of projectile that hit.
position: Vector3
The position from which the projectile was launched.
-- Here is a script that uses this event:
-- Make the shooting player burn for 5 seconds when they launch a fireball
Events.ProjectileLaunched(function(event)
if (event.shooter == nil) then
return
end
if (event.projectileType == "fireball") then
StatusEffectService.giveEffect(event.shooterEntity, StatusEffectType.BURN, 5)
end
end)
-- ProjectileHit
Parameters
shooter: Entity | nil
The entity that launched the projectile (may not exist).
projectileType: ProjectileType
The type of projectile that hit.
position: Vector3
The position that the projectile hit.
hitEntity: Entity | nil
The entity that was hit by the projectile (may not exist).
cancelled: bool [modifiable]
If set to true, the projectile hit will be cancelled.
-- Here is a script that uses this event:
Events.ProjectileHit(function(event)
-- Only continue if the projectile that hit was Whim's nature spell
if (event.projectileType == "mage_spell_nature") then
local blockAt = BlockService.getBlockAt(event.position)
if (blockAt.blockType == ItemType.DIRT) then
BlockService.placeBlock(ItemType.GRASS, event.position)
ModelService.createModel(ModelType.DAISY, blockAt.position + Vector3.new(0,2.5,0))
end
end
end)
-- StatusEffectAdded
Parameters
entity: Entity
The entity that received the status effect.
statusEffect: StatusEffectType
The type of status effect that was added to the entity.
-- Here is a script that uses this event:
Events.StatusEffectAdded(function(event)
if (event.statusEffect == StatusEffectType.NO_KNOCKBACK) then
local player = event.entity:getPlayer()
if (player == nil) then
return
end
-- Give the player a knockback baguette
InventoryService.giveItem(player, ItemType.BAGUETTE, 1, true)
end
end)
-- StatusEffectRemoved
Parameters
entity: Entity
The entity that had the status effect removed from it.
statusEffect: StatusEffectType
The type of status effect that was removed from the entity.
-- Here is a script that uses this event:
Events.StatusEffectRemoved(function(event)
if (event.statusEffect == StatusEffectType.TITANS_BLESSING) then
local player = event.entity:getPlayer()
if (player == nil) then
return
end
SoundService.playSoundForPlayer(player, SoundType.TITAN_IDLE_4)
end
end)
-- WeaponSwing
Parameters
player: Player
The player that is swinging the weapon.
weapon: ItemType
The ItemType of the weapon being swung.
hitEntity: Entity | nil
The entity that was hit by the sword swing (may not exist if the swing missed).
cancelled: bool [modifiable]
If set to true, the weapon swing will be cancelled.
-- TeamUpgradePurchased
Parameters
player: Player
The player who purchased the team upgrade.
team: Team
The team that received the team upgrade.
upgrade: TeamUpgrade
The team upgrade purchased by the player.
tier: number
The tier of team upgrade purchased by the player.
-- Here is a script that uses this event:
Events.TeamUpgradePurchase(function(event)
-- Only proceed if the Tier 3 Destruction upgrade was purchased
if (event.upgrade == TeamUpgrade.DESTRUCTION and event.tier == 3) then
local teamPlayers = event.team:getInGamePlayers()
-- Loop over all players in the team that received the upgrade
for i, player in pairs(teamPlayers) do
-- Give each team player 5 TNT blocks
InventoryService.giveItem(player, ItemType.TNT, 5)
end
end
end)
Parameters
player: Player
The player that threw the telepearl
start: Vector3
The position where the player threw the telepearl
end: Vector3
The position where the telepearl landed (where the player will teleport to)
-- Here is a script that uses this event:
-- When a player uses a telepearl, give them the Decay status effect
Events.Telepearled(function(event)
local entity = event.player:getEntity()
if (entity == nil) then
return
end
StatusEffectService.giveEffect(entity, StatusEffectType.DECAY)
end)
-- UseAbility
Parameters
entity: Entity
The entity that used the ability.
abilityName: string | AbilityType
The ability used by the entity.
cancelled: bool [modifiable]
If set to true, the ability use will be cancelled.
-- Here is a script that uses this event:
-- When a player attempts to Recall, turn them invisible for a few seconds
Events.UseAbility(function(event)
if (event.abilityName == "recall") then
StatusEffectService.giveEffect(event.entity, StatusEffectType.INVISIBILITY, 6)
end
end)