From 28b08becd1eeb6f94f04fa23dc2308e1f54945b8 Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Sat, 29 Jan 2022 21:00:22 -0300 Subject: [PATCH] add LimbType, fix broken links in docs and improve docs in general --- .../BarotraumaClient/WindowsClient.csproj | 3 + .../BarotraumaShared/Lua/DefaultLib.lua | 1 + .../BarotraumaShared/Lua/DefaultRegister.lua | 1 + .../SharedSource/Lua/LuaDocs.cs | 2 + docs/baseluadocs/AnimController.lua | 8 + docs/baseluadocs/CharacterHealth.lua | 8 + docs/lua/enums/LimbType.lua | 100 +++ docs/lua/generated/AnimController.lua | 576 ++++++++++++++++++ docs/lua/generated/CharacterHealth.lua | 335 ++++++++++ docs/lua/generated/Client.lua | 8 + docs/manual/common-questions.md | 37 ++ docs/manual/getting-started.md | 6 +- 12 files changed, 1082 insertions(+), 3 deletions(-) create mode 100644 docs/baseluadocs/AnimController.lua create mode 100644 docs/baseluadocs/CharacterHealth.lua create mode 100644 docs/lua/enums/LimbType.lua create mode 100644 docs/lua/generated/AnimController.lua create mode 100644 docs/lua/generated/CharacterHealth.lua diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index c66a7bd2d..abedb7b96 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -118,6 +118,9 @@ + + + diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultLib.lua b/Barotrauma/BarotraumaShared/Lua/DefaultLib.lua index 9570facbc..9c81b4bc9 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultLib.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultLib.lua @@ -33,6 +33,7 @@ defaultLib["Point"] = LuaUserData.CreateStatic("Microsoft.Xna.Framework.Point") defaultLib["ChatMessage"] = CreateStatic("Networking.ChatMessage") defaultLib["Hull"] = CreateStatic("Hull") defaultLib["InvSlotType"] = CreateStatic("InvSlotType") +defaultLib["LimbType"] = CreateStatic("LimbType") defaultLib["Gap"] = CreateStatic("Gap") defaultLib["ContentPackage"] = CreateStatic("ContentPackage") defaultLib["ClientPermissions"] = { diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultRegister.lua b/Barotrauma/BarotraumaShared/Lua/DefaultRegister.lua index 6424368d4..352f2c6c9 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultRegister.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultRegister.lua @@ -50,6 +50,7 @@ RegisterBarotrauma("Hull") RegisterBarotrauma("Gap") RegisterBarotrauma("PhysicsBody") RegisterBarotrauma("InvSlotType") +RegisterBarotrauma("LimbType") RegisterBarotrauma("ItemPrefab") RegisterBarotrauma("SerializableProperty") diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs index aea40f1aa..f36e55245 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaDocs.cs @@ -72,6 +72,8 @@ namespace Barotrauma { GenerateDocs(typeof(Character), "Character.lua"); GenerateDocs(typeof(CharacterInfo), "CharacterInfo.lua"); + GenerateDocs(typeof(CharacterHealth), "CharacterHealth.lua"); + GenerateDocs(typeof(AnimController), "AnimController.lua"); GenerateDocs(typeof(Client), "Client.lua"); GenerateDocs(typeof(Entity), "Entity.lua"); GenerateDocs(typeof(EntitySpawner), "Entity.Spawner.lua", "Entity.Spawner"); diff --git a/docs/baseluadocs/AnimController.lua b/docs/baseluadocs/AnimController.lua new file mode 100644 index 000000000..a0aa441f0 --- /dev/null +++ b/docs/baseluadocs/AnimController.lua @@ -0,0 +1,8 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma.AnimController +]] +-- @code AnimController +-- @pragma nostrip +local AnimController = {} \ No newline at end of file diff --git a/docs/baseluadocs/CharacterHealth.lua b/docs/baseluadocs/CharacterHealth.lua new file mode 100644 index 000000000..a67e478f0 --- /dev/null +++ b/docs/baseluadocs/CharacterHealth.lua @@ -0,0 +1,8 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma.CharacterHealth +]] +-- @code CharacterHealth +-- @pragma nostrip +local CharacterHealth = {} \ No newline at end of file diff --git a/docs/lua/enums/LimbType.lua b/docs/lua/enums/LimbType.lua new file mode 100644 index 000000000..ec1f5a238 --- /dev/null +++ b/docs/lua/enums/LimbType.lua @@ -0,0 +1,100 @@ +--[[-- +LimbType enum. +]] +-- @enum LimbType + + +--- +-- LimbType.None = 0 +-- @realm shared +-- @number LimbType.None + +--- +-- LimbType.LeftHand = 1 +-- @realm shared +-- @number LimbType.LeftHand + +--- +-- LimbType.RightHand = 2 +-- @realm shared +-- @number LimbType.RightHand + +--- +-- LimbType.LeftArm = 3 +-- @realm shared +-- @number LimbType.LeftArm + +--- +-- LimbType.RightArm = 4 +-- @realm shared +-- @number LimbType.RightArm + +--- +-- LimbType.LeftForearm = 5 +-- @realm shared +-- @number LimbType.LeftForearm + +--- +-- LimbType.RightForearm = 6 +-- @realm shared +-- @number LimbType.RightForearm + +--- +-- LimbType.LeftLeg = 7 +-- @realm shared +-- @number LimbType.LeftLeg + +--- +-- LimbType.RightLeg = 8 +-- @realm shared +-- @number LimbType.RightLeg + +--- +-- LimbType.LeftFoot = 9 +-- @realm shared +-- @number LimbType.LeftFoot + +--- +-- LimbType.RightFoot = 10 +-- @realm shared +-- @number LimbType.RightFoot + +--- +-- LimbType.Head = 11 +-- @realm shared +-- @number LimbType.Head + +--- +-- LimbType.Torso = 12 +-- @realm shared +-- @number LimbType.Torso + +--- +-- LimbType.Tail = 13 +-- @realm shared +-- @number LimbType.Tail + +--- +-- LimbType.Legs = 14 +-- @realm shared +-- @number LimbType.Legs + +--- +-- LimbType.RightThigh = 15 +-- @realm shared +-- @number LimbType.RightThigh + +--- +-- LimbType.LeftThigh = 16 +-- @realm shared +-- @number LimbType.LeftThigh + +--- +-- LimbType.Waist = 17 +-- @realm shared +-- @number LimbType.Waist + +--- +-- LimbType.Jaw = 18 +-- @realm shared +-- @number LimbType.Jaw diff --git a/docs/lua/generated/AnimController.lua b/docs/lua/generated/AnimController.lua new file mode 100644 index 000000000..98244f41c --- /dev/null +++ b/docs/lua/generated/AnimController.lua @@ -0,0 +1,576 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma.AnimController +]] +-- @code AnimController +-- @pragma nostrip +local AnimController = {} + +--- UpdateAnim +-- @realm shared +-- @tparam number deltaTime +function UpdateAnim(deltaTime) end + +--- DragCharacter +-- @realm shared +-- @tparam Character target +-- @tparam number deltaTime +function DragCharacter(target, deltaTime) end + +--- GetSpeed +-- @realm shared +-- @tparam AnimationType type +-- @treturn number +function GetSpeed(type) end + +--- GetCurrentSpeed +-- @realm shared +-- @tparam bool useMaxSpeed +-- @treturn number +function GetCurrentSpeed(useMaxSpeed) end + +--- GetAnimationParamsFromType +-- @realm shared +-- @tparam AnimationType type +-- @treturn AnimationParams +function GetAnimationParamsFromType(type) end + +--- UpdateUseItem +-- @realm shared +-- @tparam bool allowMovement +-- @tparam Vector2 handWorldPos +function UpdateUseItem(allowMovement, handWorldPos) end + +--- Grab +-- @realm shared +-- @tparam Vector2 rightHandPos +-- @tparam Vector2 leftHandPos +function Grab(rightHandPos, leftHandPos) end + +--- HoldItem +-- @realm shared +-- @tparam number deltaTime +-- @tparam Item item +-- @tparam Vector2[] handlePos +-- @tparam Vector2 holdPos +-- @tparam Vector2 aimPos +-- @tparam bool aim +-- @tparam number holdAngle +-- @tparam number itemAngleRelativeToHoldAngle +-- @tparam bool aimMelee +function HoldItem(deltaTime, item, handlePos, holdPos, aimPos, aim, holdAngle, itemAngleRelativeToHoldAngle, aimMelee) end + +--- HandIK +-- @realm shared +-- @tparam Limb hand +-- @tparam Vector2 pos +-- @tparam number armTorque +-- @tparam number handTorque +-- @tparam number maxAngularVelocity +function HandIK(hand, pos, armTorque, handTorque, maxAngularVelocity) end + +--- ApplyPose +-- @realm shared +-- @tparam Vector2 leftHandPos +-- @tparam Vector2 rightHandPos +-- @tparam Vector2 leftFootPos +-- @tparam Vector2 rightFootPos +-- @tparam number footMoveForce +function ApplyPose(leftHandPos, rightHandPos, leftFootPos, rightFootPos, footMoveForce) end + +--- ApplyTestPose +-- @realm shared +function ApplyTestPose() end + +--- Recreate +-- @realm shared +-- @tparam RagdollParams ragdollParams +function Recreate(ragdollParams) end + +--- GetMouthPosition +-- @realm shared +-- @treturn Nullable`1 +function GetMouthPosition() end + +--- GetColliderBottom +-- @realm shared +-- @treturn Vector2 +function GetColliderBottom() end + +--- FindLowestLimb +-- @realm shared +-- @treturn Limb +function FindLowestLimb() end + +--- ReleaseStuckLimbs +-- @realm shared +function ReleaseStuckLimbs() end + +--- HideAndDisable +-- @realm shared +-- @tparam LimbType limbType +-- @tparam number duration +-- @tparam bool ignoreCollisions +function HideAndDisable(limbType, duration, ignoreCollisions) end + +--- RestoreTemporarilyDisabled +-- @realm shared +function RestoreTemporarilyDisabled() end + +--- Remove +-- @realm shared +function Remove() end + +--- SubtractMass +-- @realm shared +-- @tparam Limb limb +function SubtractMass(limb) end + +--- SaveRagdoll +-- @realm shared +-- @tparam string fileNameWithoutExtension +function SaveRagdoll(fileNameWithoutExtension) end + +--- ResetRagdoll +-- @realm shared +-- @tparam bool forceReload +function ResetRagdoll(forceReload) end + +--- ResetJoints +-- @realm shared +function ResetJoints() end + +--- ResetLimbs +-- @realm shared +function ResetLimbs() end + +--- AddJoint +-- @realm shared +-- @tparam JointParams jointParams +function AddJoint(jointParams) end + +--- AddLimb +-- @realm shared +-- @tparam Limb limb +function AddLimb(limb) end + +--- RemoveLimb +-- @realm shared +-- @tparam Limb limb +function RemoveLimb(limb) end + +--- OnLimbCollision +-- @realm shared +-- @tparam Fixture f1 +-- @tparam Fixture f2 +-- @tparam Contact contact +-- @treturn bool +function OnLimbCollision(f1, f2, contact) end + +--- SeverLimbJoint +-- @realm shared +-- @tparam LimbJoint limbJoint +-- @treturn bool +function SeverLimbJoint(limbJoint) end + +--- Flip +-- @realm shared +function Flip() end + +--- GetCenterOfMass +-- @realm shared +-- @treturn Vector2 +function GetCenterOfMass() end + +--- MoveLimb +-- @realm shared +-- @tparam Limb limb +-- @tparam Vector2 pos +-- @tparam number amount +-- @tparam bool pullFromCenter +function MoveLimb(limb, pos, amount, pullFromCenter) end + +--- ResetPullJoints +-- @realm shared +function ResetPullJoints() end + +--- FindHull +-- @realm shared +-- @tparam Nullable`1 worldPosition +-- @tparam bool setSubmarine +function FindHull(worldPosition, setSubmarine) end + +--- Teleport +-- @realm shared +-- @tparam Vector2 moveAmount +-- @tparam Vector2 velocityChange +-- @tparam bool detachProjectiles +function Teleport(moveAmount, velocityChange, detachProjectiles) end + +--- Update +-- @realm shared +-- @tparam number deltaTime +-- @tparam Camera cam +function Update(deltaTime, cam) end + +--- ForceRefreshFloorY +-- @realm shared +function ForceRefreshFloorY() end + +--- SetPosition +-- @realm shared +-- @tparam Vector2 simPosition +-- @tparam bool lerp +-- @tparam bool ignorePlatforms +-- @tparam bool forceMainLimbToCollider +-- @tparam bool detachProjectiles +function SetPosition(simPosition, lerp, ignorePlatforms, forceMainLimbToCollider, detachProjectiles) end + +--- Hang +-- @realm shared +function Hang() end + +--- GetLimb +-- @realm shared +-- @tparam LimbType limbType +-- @tparam bool excludeSevered +-- @treturn Limb +function GetLimb(limbType, excludeSevered) end + +--- GetType +-- @realm shared +-- @treturn Type +function GetType() end + +--- ToString +-- @realm shared +-- @treturn string +function ToString() end + +--- Equals +-- @realm shared +-- @tparam Object obj +-- @treturn bool +function Equals(obj) end + +--- GetHashCode +-- @realm shared +-- @treturn number +function GetHashCode() end + +--- +-- RightHandIKPos, Field of type Vector2 +-- @realm shared +-- @Vector2 RightHandIKPos + +--- +-- LeftHandIKPos, Field of type Vector2 +-- @realm shared +-- @Vector2 LeftHandIKPos + +--- +-- IsAiming, Field of type bool +-- @realm shared +-- @bool IsAiming + +--- +-- IsAimingMelee, Field of type bool +-- @realm shared +-- @bool IsAimingMelee + +--- +-- ArmLength, Field of type number +-- @realm shared +-- @number ArmLength + +--- +-- WalkParams, Field of type GroundedMovementParams +-- @realm shared +-- @GroundedMovementParams WalkParams + +--- +-- RunParams, Field of type GroundedMovementParams +-- @realm shared +-- @GroundedMovementParams RunParams + +--- +-- SwimSlowParams, Field of type SwimParams +-- @realm shared +-- @SwimParams SwimSlowParams + +--- +-- SwimFastParams, Field of type SwimParams +-- @realm shared +-- @SwimParams SwimFastParams + +--- +-- CurrentAnimationParams, Field of type AnimationParams +-- @realm shared +-- @AnimationParams CurrentAnimationParams + +--- +-- ForceSelectAnimationType, Field of type AnimationType +-- @realm shared +-- @AnimationType ForceSelectAnimationType + +--- +-- CurrentGroundedParams, Field of type GroundedMovementParams +-- @realm shared +-- @GroundedMovementParams CurrentGroundedParams + +--- +-- CurrentSwimParams, Field of type SwimParams +-- @realm shared +-- @SwimParams CurrentSwimParams + +--- +-- CanWalk, Field of type bool +-- @realm shared +-- @bool CanWalk + +--- +-- IsMovingBackwards, Field of type bool +-- @realm shared +-- @bool IsMovingBackwards + +--- +-- IsMovingFast, Field of type bool +-- @realm shared +-- @bool IsMovingFast + +--- +-- AllAnimParams, Field of type table +-- @realm shared +-- @table AllAnimParams + +--- +-- AimSourceWorldPos, Field of type Vector2 +-- @realm shared +-- @Vector2 AimSourceWorldPos + +--- +-- AimSourcePos, Field of type Vector2 +-- @realm shared +-- @Vector2 AimSourcePos + +--- +-- AimSourceSimPos, Field of type Vector2 +-- @realm shared +-- @Vector2 AimSourceSimPos + +--- +-- HeadPosition, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 HeadPosition + +--- +-- TorsoPosition, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 TorsoPosition + +--- +-- HeadAngle, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 HeadAngle + +--- +-- TorsoAngle, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 TorsoAngle + +--- +-- StepSize, Field of type Nullable`1 +-- @realm shared +-- @Nullable`1 StepSize + +--- +-- AnimationTestPose, Field of type bool +-- @realm shared +-- @bool AnimationTestPose + +--- +-- WalkPos, Field of type number +-- @realm shared +-- @number WalkPos + +--- +-- RagdollParams, Field of type RagdollParams +-- @realm shared +-- @RagdollParams RagdollParams + +--- +-- Limbs, Field of type Limb[] +-- @realm shared +-- @Limb[] Limbs + +--- +-- HasMultipleLimbsOfSameType, Field of type bool +-- @realm shared +-- @bool HasMultipleLimbsOfSameType + +--- +-- Frozen, Field of type bool +-- @realm shared +-- @bool Frozen + +--- +-- Character, Field of type Character +-- @realm shared +-- @Character Character + +--- +-- OnGround, Field of type bool +-- @realm shared +-- @bool OnGround + +--- +-- ColliderHeightFromFloor, Field of type number +-- @realm shared +-- @number ColliderHeightFromFloor + +--- +-- IsStuck, Field of type bool +-- @realm shared +-- @bool IsStuck + +--- +-- Collider, Field of type PhysicsBody +-- @realm shared +-- @PhysicsBody Collider + +--- +-- ColliderIndex, Field of type number +-- @realm shared +-- @number ColliderIndex + +--- +-- FloorY, Field of type number +-- @realm shared +-- @number FloorY + +--- +-- Mass, Field of type number +-- @realm shared +-- @number Mass + +--- +-- MainLimb, Field of type Limb +-- @realm shared +-- @Limb MainLimb + +--- +-- WorldPosition, Field of type Vector2 +-- @realm shared +-- @Vector2 WorldPosition + +--- +-- SimplePhysicsEnabled, Field of type bool +-- @realm shared +-- @bool SimplePhysicsEnabled + +--- +-- TargetMovement, Field of type Vector2 +-- @realm shared +-- @Vector2 TargetMovement + +--- +-- ImpactTolerance, Field of type number +-- @realm shared +-- @number ImpactTolerance + +--- +-- Draggable, Field of type bool +-- @realm shared +-- @bool Draggable + +--- +-- CanEnterSubmarine, Field of type bool +-- @realm shared +-- @bool CanEnterSubmarine + +--- +-- Dir, Field of type number +-- @realm shared +-- @number Dir + +--- +-- Direction, Field of type Direction +-- @realm shared +-- @Direction Direction + +--- +-- InWater, Field of type bool +-- @realm shared +-- @bool InWater + +--- +-- HeadInWater, Field of type bool +-- @realm shared +-- @bool HeadInWater + +--- +-- CurrentHull, Field of type Hull +-- @realm shared +-- @Hull CurrentHull + +--- +-- IgnorePlatforms, Field of type bool +-- @realm shared +-- @bool IgnorePlatforms + +--- +-- IsFlipped, Field of type bool +-- @realm shared +-- @bool IsFlipped + +--- +-- BodyInRest, Field of type bool +-- @realm shared +-- @bool BodyInRest + +--- +-- Invalid, Field of type bool +-- @realm shared +-- @bool Invalid + +--- +-- IsHanging, Field of type bool +-- @realm shared +-- @bool IsHanging + +--- +-- Anim, Field of type Animation +-- @realm shared +-- @Animation Anim + +--- +-- LimbJoints, Field of type LimbJoint[] +-- @realm shared +-- @LimbJoint[] LimbJoints + +--- +-- movement, Field of type Vector2 +-- @realm shared +-- @Vector2 movement + +--- +-- Stairs, Field of type Structure +-- @realm shared +-- @Structure Stairs + +--- +-- TargetDir, Field of type Direction +-- @realm shared +-- @Direction TargetDir + +--- +-- forceStanding, Field of type bool +-- @realm shared +-- @bool forceStanding + +--- +-- forceNotStanding, Field of type bool +-- @realm shared +-- @bool forceNotStanding + diff --git a/docs/lua/generated/CharacterHealth.lua b/docs/lua/generated/CharacterHealth.lua new file mode 100644 index 000000000..10d921d95 --- /dev/null +++ b/docs/lua/generated/CharacterHealth.lua @@ -0,0 +1,335 @@ +-- luacheck: ignore 111 + +--[[-- +Barotrauma.CharacterHealth +]] +-- @code CharacterHealth +-- @pragma nostrip +local CharacterHealth = {} + +--- GetAllAfflictions +-- @realm shared +-- @treturn IReadOnlyCollection`1 +function GetAllAfflictions() end + +--- GetAllAfflictions +-- @realm shared +-- @tparam function limbHealthFilter +-- @treturn Enumerable +function GetAllAfflictions(limbHealthFilter) end + +--- GetAffliction +-- @realm shared +-- @tparam string identifier +-- @tparam bool allowLimbAfflictions +-- @treturn Affliction +function GetAffliction(identifier, allowLimbAfflictions) end + +--- GetAfflictionOfType +-- @realm shared +-- @tparam string afflictionType +-- @tparam bool allowLimbAfflictions +-- @treturn Affliction +function GetAfflictionOfType(afflictionType, allowLimbAfflictions) end + +--- GetAffliction +-- @realm shared +-- @tparam string identifier +-- @tparam bool allowLimbAfflictions +-- @treturn T +function GetAffliction(identifier, allowLimbAfflictions) end + +--- GetAffliction +-- @realm shared +-- @tparam string identifier +-- @tparam Limb limb +-- @treturn Affliction +function GetAffliction(identifier, limb) end + +--- GetAfflictionLimb +-- @realm shared +-- @tparam Affliction affliction +-- @treturn Limb +function GetAfflictionLimb(affliction) end + +--- GetAfflictionStrength +-- @realm shared +-- @tparam string afflictionType +-- @tparam Limb limb +-- @tparam bool requireLimbSpecific +-- @treturn number +function GetAfflictionStrength(afflictionType, limb, requireLimbSpecific) end + +--- GetAfflictionStrength +-- @realm shared +-- @tparam string afflictionType +-- @tparam bool allowLimbAfflictions +-- @treturn number +function GetAfflictionStrength(afflictionType, allowLimbAfflictions) end + +--- ApplyAffliction +-- @realm shared +-- @tparam Limb targetLimb +-- @tparam Affliction affliction +-- @tparam bool allowStacking +function ApplyAffliction(targetLimb, affliction, allowStacking) end + +--- GetResistance +-- @realm shared +-- @tparam AfflictionPrefab afflictionPrefab +-- @treturn number +function GetResistance(afflictionPrefab) end + +--- GetStatValue +-- @realm shared +-- @tparam StatTypes statType +-- @treturn number +function GetStatValue(statType) end + +--- HasFlag +-- @realm shared +-- @tparam AbilityFlags flagType +-- @treturn bool +function HasFlag(flagType) end + +--- ReduceAffliction +-- @realm shared +-- @tparam Limb targetLimb +-- @tparam string afflictionIdentifier +-- @tparam number amount +-- @tparam Nullable`1 treatmentAction +function ReduceAffliction(targetLimb, afflictionIdentifier, amount, treatmentAction) end + +--- ApplyDamage +-- @realm shared +-- @tparam Limb hitLimb +-- @tparam AttackResult attackResult +-- @tparam bool allowStacking +function ApplyDamage(hitLimb, attackResult, allowStacking) end + +--- SetAllDamage +-- @realm shared +-- @tparam number damageAmount +-- @tparam number bleedingDamageAmount +-- @tparam number burnDamageAmount +function SetAllDamage(damageAmount, bleedingDamageAmount, burnDamageAmount) end + +--- GetLimbDamage +-- @realm shared +-- @tparam Limb limb +-- @tparam string afflictionType +-- @treturn number +function GetLimbDamage(limb, afflictionType) end + +--- RemoveAllAfflictions +-- @realm shared +function RemoveAllAfflictions() end + +--- RemoveNegativeAfflictions +-- @realm shared +function RemoveNegativeAfflictions() end + +--- Update +-- @realm shared +-- @tparam number deltaTime +function Update(deltaTime) end + +--- SetVitality +-- @realm shared +-- @tparam number newVitality +function SetVitality(newVitality) end + +--- CalculateVitality +-- @realm shared +function CalculateVitality() end + +--- ApplyAfflictionStatusEffects +-- @realm shared +-- @tparam function type +function ApplyAfflictionStatusEffects(type) end + +--- GetCauseOfDeath +-- @realm shared +-- @treturn ValueTuple`2 +function GetCauseOfDeath() end + +--- GetSuitableTreatments +-- @realm shared +-- @tparam table treatmentSuitability +-- @tparam bool normalize +-- @tparam Limb limb +-- @tparam bool ignoreHiddenAfflictions +-- @tparam number predictFutureDuration +function GetSuitableTreatments(treatmentSuitability, normalize, limb, ignoreHiddenAfflictions, predictFutureDuration) end + +--- GetActiveAfflictionTags +-- @realm shared +-- @treturn Enumerable +function GetActiveAfflictionTags() end + +--- GetActiveAfflictionTags +-- @realm shared +-- @tparam Enumerable afflictions +-- @treturn Enumerable +function GetActiveAfflictionTags(afflictions) end + +--- GetPredictedStrength +-- @realm shared +-- @tparam Affliction affliction +-- @tparam number predictFutureDuration +-- @tparam Limb limb +-- @treturn number +function GetPredictedStrength(affliction, predictFutureDuration, limb) end + +--- ServerWrite +-- @realm shared +-- @tparam IWriteMessage msg +function ServerWrite(msg) end + +--- Remove +-- @realm shared +function Remove() end + +--- SortAfflictionsBySeverity +-- @realm shared +-- @tparam Enumerable afflictions +-- @tparam bool excludeBuffs +-- @treturn Enumerable +function CharacterHealth.SortAfflictionsBySeverity(afflictions, excludeBuffs) end + +--- Save +-- @realm shared +-- @tparam XElement healthElement +function Save(healthElement) end + +--- Load +-- @realm shared +-- @tparam XElement element +function Load(element) end + +--- GetType +-- @realm shared +-- @treturn Type +function GetType() end + +--- ToString +-- @realm shared +-- @treturn string +function ToString() end + +--- Equals +-- @realm shared +-- @tparam Object obj +-- @treturn bool +function Equals(obj) end + +--- GetHashCode +-- @realm shared +-- @treturn number +function GetHashCode() end + +--- +-- DoesBleed, Field of type bool +-- @realm shared +-- @bool DoesBleed + +--- +-- UseHealthWindow, Field of type bool +-- @realm shared +-- @bool UseHealthWindow + +--- +-- CrushDepth, Field of type number +-- @realm shared +-- @number CrushDepth + +--- +-- IsUnconscious, Field of type bool +-- @realm shared +-- @bool IsUnconscious + +--- +-- PressureKillDelay, Field of type number +-- @realm shared +-- @number PressureKillDelay + +--- +-- Vitality, Field of type number +-- @realm shared +-- @number Vitality + +--- +-- HealthPercentage, Field of type number +-- @realm shared +-- @number HealthPercentage + +--- +-- MaxVitality, Field of type number +-- @realm shared +-- @number MaxVitality + +--- +-- MinVitality, Field of type number +-- @realm shared +-- @number MinVitality + +--- +-- FaceTint, Field of type Color +-- @realm shared +-- @Color FaceTint + +--- +-- BodyTint, Field of type Color +-- @realm shared +-- @Color BodyTint + +--- +-- OxygenAmount, Field of type number +-- @realm shared +-- @number OxygenAmount + +--- +-- BloodlossAmount, Field of type number +-- @realm shared +-- @number BloodlossAmount + +--- +-- Stun, Field of type number +-- @realm shared +-- @number Stun + +--- +-- StunTimer, Field of type number +-- @realm shared +-- @number StunTimer + +--- +-- PressureAffliction, Field of type Affliction +-- @realm shared +-- @Affliction PressureAffliction + +--- +-- Character, Field of type Character +-- @realm shared +-- @Character Character + +--- +-- Unkillable, Field of type bool +-- @realm shared +-- @bool Unkillable + +--- +-- DefaultFaceTint, Field of type Color +-- @realm shared +-- @Color DefaultFaceTint + +--- +-- CharacterHealth.InsufficientOxygenThreshold, Field of type number +-- @realm shared +-- @number CharacterHealth.InsufficientOxygenThreshold + +--- +-- CharacterHealth.LowOxygenThreshold, Field of type number +-- @realm shared +-- @number CharacterHealth.LowOxygenThreshold + diff --git a/docs/lua/generated/Client.lua b/docs/lua/generated/Client.lua index 2573d47ad..dab2b8e11 100644 --- a/docs/lua/generated/Client.lua +++ b/docs/lua/generated/Client.lua @@ -37,6 +37,14 @@ function CheckPermission(permissions) end function Client.Unban(player, endpoint) end +--- Ban +-- @realm shared +-- @tparam string player +-- @tparam string reason +-- @tparam bool range +-- @tparam number seconds +function Client.Ban(player, reason, range, seconds) end + --- InitClientSync -- @realm shared function InitClientSync() end diff --git a/docs/manual/common-questions.md b/docs/manual/common-questions.md index 8a76bff4a..31bf1bed2 100644 --- a/docs/manual/common-questions.md +++ b/docs/manual/common-questions.md @@ -74,3 +74,40 @@ Entity.Spawner.AddToSpawnQueue(prefab, firstPlayerCharacter.Inventory, nil, nil, print(item.Name .. " Has been spawned.") end) ``` + +## How do i give a character a certain affliction + +```lua +local burnPrefab + +for k, v in pairs(AfflictionPrefab.ListArray) do + if v.Identifier == "burn" then + burnPrefab = v + break + end +end + +local char = Character.CharacterList[1] +local limb = char.AnimController.MainLimb +-- or char.AnimController.Limbs[1] + +char.CharacterHealth.ApplyAffliction(limb, burnPrefab.Instantiate(100)) + +``` + +## How do i get the amount of a affliction that a character has? + +```lua +local char = Character.CharacterList[1] + +print(char.CharacterHealth.GetAffliction("burn")) +-- or +print(char.CharacterHealth.GetAffliction("burn", char.AnimController.Limbs[1])) +``` + +## How do i send a private chat message? + +```lua +local chatMessage = ChatMessage.Create("Sender name", "text here", ChatMessageType.MessageBox, nil, nil) +Game.SendDirectChatMessage(chatMessage, ChatMessageType.MessageBox) +``` \ No newline at end of file diff --git a/docs/manual/getting-started.md b/docs/manual/getting-started.md index 2bde81102..9eafd0124 100644 --- a/docs/manual/getting-started.md +++ b/docs/manual/getting-started.md @@ -3,14 +3,14 @@ If you want to learn how Lua works and the syntax, you can check these websites: [https://www.lua.org/manual/5.2/](https://www.lua.org/manual/5.2/) [https://www.tutorialspoint.com/lua/lua_overview.htm](https://www.tutorialspoint.com/lua/lua_overview.htm) ## How mods are executed -When the server finishes loading everything, Lua For Barotrauma starts up and reads the file `Lua/LuaSetup.lua` and executes it, this Lua script registers classes to be available on the Lua side, creates static references and puts them in the global space, and then executes the mod's autorun folder. By default it only executes mods enabled in the settings menu, you can bypass that by editing the file `LuaSetup.lua` and setting `local runDisabledMods = false` to `local runDisabledMods = true`. +When the server finishes loading everything, Lua For Barotrauma starts up and reads the file `Lua/LuaSetup.lua` and executes it, this Lua script registers classes to be available on the Lua side, creates static references and puts them in the global space, and then goes on each mod and executes the mod's autorun folder. By default it only executes mods enabled in the settings menu, you can bypass that by editing the file `LuaSetup.lua` and setting `local runDisabledMods = false` to `local runDisabledMods = true`. ## Creating your first mod When creating a new Lua mod, you will need to create a new folder on the **Mods** folder, then inside this folder you will need to create a folder called **Lua**, and then inside the Lua folder you create a folder called **Autorun**, inside this folder you can add your Lua scripts that will be executed automatically, it will look something like this `Mods/MyMod/Lua/Autorun/test.lua`, remember that if you are using the default LuaSetup settings, your mod will only be executed if its enabled in the game's settings, so you will need to create a `filelist.xml` as unusual. -Now you can open **test.lua** in your favorite text editor (vscode recommended) and type in **print("Hello, world")**, now start the server by hosting a game or running the server executable manually, you will see in your console a text appear with the text that you entered in print, you can now type in the server console `reloadlua`, this will re-execute all the Lua scripts. You can also type in `lua yourscript` to run a short lua snippet, like this `lua print('Hello, world')`, remember to remove double quotes, because Barotrauma console automatically formats those. +Now you can open **test.lua** in your favorite text editor (VSCode with the Lua Sumneko extension recommended) and type in **print("Hello, world")**, now start the server by hosting a game or running the server executable manually, you will see in your console a text appear with the text that you entered in print, you can now type in the server console `reloadlua`, this will re-execute all the Lua scripts. You can also type in `lua yourscript` to run a short lua snippet, like this `lua print('Hello, world')`, remember to remove double quotes, because Barotrauma console automatically formats those. ## Learning the libraries In the sidebar of the documentation, you can see a tab named Code, in there you can check out all the functions and fields that each class has, each one of them has a box with a color on it, where means Server-Side, means Client-Side and means both Server-Side and Client-Side, by clicking on them you can learn more about them. Not everything is documented here, theres stuff missing that still needs to be added, if you want to find more in-depth functions and fields in the Barotrauma classes, you should check the Barotrauma source code. -See Lua Examples, Common Questions \ No newline at end of file +See Lua Examples, Common Questions \ No newline at end of file