update Lua examples

This commit is contained in:
Evil Factory
2022-04-20 12:54:33 -03:00
parent 928428cabd
commit 0a747c42fd
+4 -4
View File
@@ -14,7 +14,7 @@ end)
``` ```
Hook.Add("itemApplyTreatment", "testItemApplyTreatment", function (item, user, character, targetlimb) Hook.Add("itemApplyTreatment", "testItemApplyTreatment", function (item, user, character, targetlimb)
if item.name == "Bandage" then if item.Prefab.Identifier == "antibleeding1" then
local pos = character.WorldPosition local pos = character.WorldPosition
Game.Explode(pos, 1, 500, 5000, 5000, 5000) Game.Explode(pos, 1, 500, 5000, 5000, 5000)
@@ -29,7 +29,7 @@ end)
``` ```
-- for example: create an item in xml named RandomComponent and add the wiring inputs/outputs trigger_random and random_out -- for example: create an item in xml named RandomComponent and add the wiring inputs/outputs trigger_random and random_out
Hook.Add("signalReceived", "signalReceivedTest", function (signal, connection) Hook.Add("signalReceived", "signalReceivedTest", function (signal, connection)
if connection.Item.name == "RandomComponent" and connection.Name == "trigger_random" then if connection.Item.Prefab.Identifier == "RandomComponent" and connection.Name == "trigger_random" then
connection.Item.SendSignal(tostring(Random.Range(0, 100)), "random_out") connection.Item.SendSignal(tostring(Random.Range(0, 100)), "random_out")
end end
end) end)
@@ -72,13 +72,13 @@ Hook.Add("chatMessage","controlhuskcommand",function(msg, client)
local suitablechars = {} local suitablechars = {}
for i = 1, #chars, 1 do for i = 1, #chars, 1 do
local charat = chars[i] local charat = chars[i]
if not charat.IsDead and string.match(string.lower(charat.SpeciesName), "husk") and not charat.IsRemotelyControlled then if not charat.IsDead and string.match(string.lower(charat.SpeciesName.Value), "husk") and not charat.IsRemotelyControlled then
table.insert(suitablechars, charat) table.insert(suitablechars, charat)
end end
end end
if #suitablechars >= 1 then if #suitablechars >= 1 then
Player.SetClientCharacter(client, suitablechars[Random.Range(1, #suitablechars)]) client.SetClientCharacter(suitablechars[Random.Range(1, #suitablechars)])
end end
return true -- hide message return true -- hide message