-
Notifications
You must be signed in to change notification settings - Fork 0
Adding SF Functions
LengthenedGradient edited this page Apr 9, 2024
·
7 revisions
All your edits should go in ACF-3\lua\starfall\libs_sh\acffunctions.lua

The top of the file contains localized global functions and some permissions.

Next comes the helper functions, which can be used in the SF functions.

This sets up the SF library.

Everything here and below contains the actual functions SF will call.
Example
--- Returns current ACF drag divisor
-- @shared
-- @return number The current drag divisor
function acf_library.dragDivisor()
return ACF.DragDiv
end
--- Returns the effective armor given an armor value and hit angle
-- @shared
-- @param number Armor The nominal armor value
-- @param number Angle The hit angle
-- @return number The effective armor
function acf_library.effectiveArmor(armor, angle)
CheckLuaType(armor, TYPE_NUMBER)
CheckLuaType(angle, TYPE_NUMBER)
return math.Round(armor / math.abs(math.cos(math.rad(math.min(angle, 89.999)))), 1)
endEach function needs to follow the above format. (Replace the <> with what you need):
--- <Function Description>-
-- @<shared/client/serverdepending on the realm the -
-- @param <type> <Name>for every argument, if your function has inputs -
-- @return <type> <Description>if your function returns something. function acf_library.<functionName>(<arg1,arg2,...>) <function body> end