Skip to content

Instantly share code, notes, and snippets.

@AbigailBuccaneer
Created September 8, 2017 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbigailBuccaneer/1faa65b1a8305b7f6e03005f17398ac9 to your computer and use it in GitHub Desktop.
Save AbigailBuccaneer/1faa65b1a8305b7f6e03005f17398ac9 to your computer and use it in GitHub Desktop.
-- Loading this file (by placing it in lua/autorun, for example) will cause all
-- calls to entity:SetMaxHealth() to be duplicated (by all duplicators).
--
-- Caution! This code has never been tested. It's never even been executed.
--
-- To the extent possible under law, the author(s) have dedicated all copyright
-- and related and neighboring rights to this software to the public domain
-- worldwide. This software is distributed without any warranty.
do
local entity = assert(FindMetaTable("Entity"))
local f = assert(meta.SetMaxHealth)
duplicator.RegisterEntityModifier("MaxHealth", function(player, entity, data)
f(entity, data.value)
end)
function entity:SetMaxHealth(value)
f(self, value)
duplicator.StoreEntityModifier(self, "MaxHealth", { value = value })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment