Reputation:
I'm making an addon in Lua and in a config file, I have marked RankName = "Whatever"
If I want to then call this back in another file and check what rank that player is, how would I pass this over? Here's part of the config code that I want to be able to pass over to another file
TimeRewards:Add( {
RankName = "Regular",
TimeRequire = { days = 0, hours = 3, mins = 0 },
Reward = function( ply )
ply:ChatPrint( "You are now a regular on the server,
ply:addMoney( 50000 )
ply:ChatPrint( "You were rewared $50000 for achieving!" )
end
} )
I need to use the RankName()
in a file to check if they are a high enough rank so, if RankName() == "Regular" then ...
Upvotes: 0
Views: 77
Reputation: 2965
You can create a module that could be required on the other file.
here you have some example extract from modules
local mymodule = {}
function mymodule.foo()
print("Hello World!")
end
return mymodule
on the other file
local mymodule = require "mymodule"
mymodule.foo()
maybe you could return that values on the modue
Upvotes: 1