rename hooks, introduce statusEffect.apply and update docs
This commit is contained in:
@@ -2343,7 +2343,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (condition == 0.0f) { return; }
|
if (condition == 0.0f) { return; }
|
||||||
|
|
||||||
var should = new LuaResult(GameMain.Lua.hook.Call("itemUse", new object[] { this, character, targetLimb }));
|
var should = new LuaResult(GameMain.Lua.hook.Call("item.use", new object[] { this, character, targetLimb }));
|
||||||
|
|
||||||
if (should.Bool())
|
if (should.Bool())
|
||||||
return;
|
return;
|
||||||
@@ -2381,7 +2381,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (condition == 0.0f) { return; }
|
if (condition == 0.0f) { return; }
|
||||||
|
|
||||||
var should = new LuaResult(GameMain.Lua.hook.Call("itemSecondaryUse", new object[] { this, character}));
|
var should = new LuaResult(GameMain.Lua.hook.Call("item.secondaryUse", new object[] { this, character}));
|
||||||
|
|
||||||
if (should.Bool())
|
if (should.Bool())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1138,7 +1138,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (entity is Item item)
|
if (entity is Item item)
|
||||||
{
|
{
|
||||||
GameMain.Lua.hook.Call("statusEffect.apply." + item.Prefab.Identifier, this, deltaTime, entity, targets, worldPosition);
|
var result = new LuaResult(GameMain.Lua.hook.Call("statusEffect.apply." + item.Prefab.Identifier, this, deltaTime, entity, targets, worldPosition));
|
||||||
|
|
||||||
|
if (result.Bool())
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-12
@@ -88,34 +88,33 @@ function afflictionApplied(affliction, characterHealth, limb) end
|
|||||||
function afflictionUpdate(affliction, characterHealth, limb) end
|
function afflictionUpdate(affliction, characterHealth, limb) end
|
||||||
--- Gets called every time an Item gets "Used".
|
--- Gets called every time an Item gets "Used".
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemUse(item, itemUser, targetLimb) end
|
function item.use(item, itemUser, targetLimb) end
|
||||||
--- Same as itemUse.
|
--- Same as itemUse.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemSecondaryUse(item, itemUser) end
|
function item.secondaryUse(item, itemUser) end
|
||||||
--- Gets called whenever an item is used as a treatment (eg. bandages).
|
--- Gets called whenever an item is used as a treatment (eg. bandages).
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemApplyTreatment(item, usingCharacter, targetCharacter, limb) end
|
function item.applyTreatment(item, usingCharacter, targetCharacter, limb) end
|
||||||
|
|
||||||
--- Gets called whenever an item is dropped, You can return true to cancel.
|
--- Gets called whenever an item is dropped, You can return true to cancel.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemDrop(item, character) end
|
function item.drop(item, character) end
|
||||||
|
|
||||||
--- Gets called whenever an item is equipped. Return true to cancel.
|
--- Gets called whenever an item is equipped. Return true to cancel.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemEquip(item, character) end
|
function item.equip(item, character) end
|
||||||
|
|
||||||
--- Same as itemEquip, but for unequipping.
|
--- Same as itemEquip, but for unequipping.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemUnequip(item, character) end
|
function item.unequip(item, character) end
|
||||||
|
|
||||||
--- Gets called every time an item is interacted, eg: picking item on ground, fixing something with wrench
|
--- Gets called every time an item is interacted, eg: picking item on ground, fixing something with wrench
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemInteract(item, characterPicker, ignoreRequiredItemsBool, forceSelectKeyBool, forceActionKeyBool) end
|
function item.interact(item, characterPicker, ignoreRequiredItemsBool, forceSelectKeyBool, forceActionKeyBool) end
|
||||||
|
|
||||||
--- Gets called every time two items are combined, eg: drag an half empty magazine to another half empty magazine to combine
|
--- Gets called every time two items are combined, eg: drag an half empty magazine to another half empty magazine to combine
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function itemCombine(item, otherItem, userCharacter) end
|
function item.combine(item, otherItem, userCharacter) end
|
||||||
|
|
||||||
|
|
||||||
--- Gets called every time an item is moved from one inventory slot to another, return true to cancel
|
--- Gets called every time an item is moved from one inventory slot to another, return true to cancel
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
@@ -137,9 +136,9 @@ function gapOxygenUpdate(gap, hull1, hull2) end
|
|||||||
-- @realm shared
|
-- @realm shared
|
||||||
function signalReceived(signal, connection) end
|
function signalReceived(signal, connection) end
|
||||||
|
|
||||||
--- Same as signalReceived, but gets called only when needed by specifying your component, better performance.
|
--- Gets called everytime the specified item receives a signal.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function signalReceived.YourComponentIdentifier(signal, connection) end
|
function signalReceived.YourItemIdentifier(signal, connection) end
|
||||||
|
|
||||||
--- Gets called everytime a WifiComponent starts transmitting a signal
|
--- Gets called everytime a WifiComponent starts transmitting a signal
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
@@ -185,4 +184,23 @@ function traitor.traitorAssigned(traitor) end
|
|||||||
|
|
||||||
--- Return true to accept traitor candidate.
|
--- Return true to accept traitor candidate.
|
||||||
-- @realm shared
|
-- @realm shared
|
||||||
function traitor.findTraitorCandidate(character, team) end
|
function traitor.findTraitorCandidate(character, team) end
|
||||||
|
|
||||||
|
--- Called when a melee weapon has impacted a physical object.
|
||||||
|
-- @realm shared
|
||||||
|
function meleeWeapon.handleImpact(meleeComponent, targetBody) end
|
||||||
|
|
||||||
|
--- Called when a status effect is applied to the specified item, useful for things like medical items. You can also return true to cancel out the status effect.
|
||||||
|
-- @realm shared
|
||||||
|
-- @usage
|
||||||
|
-- Hook.Add("statusEffect.apply.antibleeding1", "test", function (effect, deltaTime, item, targets, worldPosition)
|
||||||
|
-- if effect.type == ActionType.OnUse then
|
||||||
|
-- print(effect, ' ', item, ' ', targets[3])
|
||||||
|
-- return true
|
||||||
|
-- end
|
||||||
|
--end)
|
||||||
|
function statusEffect.apply.YourItemIdentifier(statusEffect, deltaTime, item, targets, worldPosition) end
|
||||||
|
|
||||||
|
--- Called when a client tries to change his name, return false to prevent the name from being changed.
|
||||||
|
-- @realm shared
|
||||||
|
function tryChangeClientName(client, newName, newJob, newTeam) end
|
||||||
|
|||||||
Reference in New Issue
Block a user