Public members
Public members are closely related to private members in that they do mostly the same, the difference is that public members don't get their names randomized, and can be used outside the scope. For a variable/function declared as public in an scope called SCP
you can just use the declared function/variable name inside the scope, but to use it outside of the scope you call it with an SCP_preffix
.
An example should be easier to understand:
library cookiesystem
public function ko takes nothing returns nothing
call BJDebugMsg("a")
endfunction
function thisisnotpublicnorprivate takes nothing returns nothing
call ko()
call cookiesystem_ko() //cookiesystem_ preffix is optional
endfunction
endlibrary
function outside takes nothing returns nothing
call cookiesystem_ko() //cookiesystem_ preffix is required
endfunction
Public function members can be used by ExecuteFunc
or real variable value events, but they always need the scope prefix when used as string:
library cookiesystem
public function ko takes nothing returns nothing
call BJDebugMsg("a")
endfunction
function thisisnotpublicnorprivate takes nothing returns nothing
call ExecuteFunc("cookiesystem_ko") //Needs the prefix no matter it is inside the scope
call ExecuteFunc("ko") //This will most likely crash the game.
call cookiesystem_ko() //Does not need the prefix but can use it.
call ko() //since it doesn't need the prefix, the line works correctly.
endfunction
endlibrary
Alternatively, you may use SCOPE_PREFIX.
Last modified: 16 October 2024