Created
April 12, 2020 19:06
-
-
Save JJK96/6d9e5b9e9bfa66c8ec90de3b1914feb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Create a console variable so you can turn metalthok on and off | |
-- By typing `metalthok On` or `metalthok Off` in console. | |
local MetalThok = CV_RegisterVar{ | |
name = "metalthok", -- name of the command | |
defaultvalue = 0, -- off by default | |
flags = CV_NETVAR, --Works over the network, so the same in the whole server for all users | |
PossibleValue = CV_OnOff --It's an On/Off value | |
} | |
-- This function us executed every frame, for each player | |
addHook("PlayerThink",function(player) | |
-- If a player is not in the game, do not execute any further, do nothing. `return` leaves the function immediately. | |
if not(player.mo and player.mo.valid) then return end | |
-- if the skin is not metalsonic | |
end | |
if player.mo.skin != "metalsonic" then | |
player.metalthok = false -- metalthok is not enabled for this player | |
return end | |
-- Get the properties of the player's skin | |
local skin = skins[player.mo.skin] | |
-- If metalthok should be on, but is off | |
if MetalThok.value and not(player.metalthok) then | |
-- Set the ability to the same as sonic's | |
player.charability = CA_THOK | |
player.actionspd = 60*FRACUNIT --fracunit is some constant, related to the fps I think | |
player.jumpfactor = 1*FRACUNIT | |
player.charflags = SF_MACHINE|SF_SUPER -- sone properties of the skin | |
player.metalthok = true --metalthok is enabled for this player | |
end | |
-- If metalthok should be off, but is on for the player | |
if not(MetalThok.value) and player.metalthok then | |
-- Set the ability to that of the skib of the player | |
player.charability = skin.ability | |
player.actionspd = skin.actionspd*FRACUNIT | |
player.charflags = skin.flags | |
player.metalthok = false --metalthok is now off for the player | |
end | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment