Currently the developers are putting their own money into JC2-MP to keep the servers online.

Please take a few seconds of your time and disable your AdBlock plugin for our website.

Ad revenue is not going to developers, it is used purely for covering our hosting costs.

 

You are also free to donate, which removes all ads from our website!

Patch 0.3 was just released! Full changelog here: https://t.co/4A50m6IKen

11 months ago

April 21, 2018, 12:21:33 am

Author Topic: luacheck globals table  (Read 633 times)

SinisterRectus

  • JC2-MP Betatester
  • Sr. Member
  • *****
  • Posts: 450
    • View Profile
luacheck globals table
« on: May 31, 2017, 10:24:05 pm »
If you use luacheck to lint your JC2MP files, then this might be useful for you. It is a list of definitions for JC2MP classes, enumerations, and functions. Simply drop it into any directory that contain your Lua files, or any directory above that one, recursively.

.luacheckrc file here

Code used to generate the list:

~ client ~
Code: [Select]
Events:Subscribe('ModuleLoad', function()
local globals = {}
for k in pairs(_G) do
if k:find('^%u') then
globals[k] = true
end
end
Network:Send('luacheck', globals)
end)

~ server ~
Code: [Select]
Network:Subscribe('luacheck', function(globals)
for k in pairs(_G) do
if k:find('^%u') then
globals[k] = true
end
end
local sorted = {}
for k in pairs(globals) do
table.insert(sorted, k)
end
table.sort(sorted)
local f = io.open('.luacheckrc', 'w')
f:write('globals = { -- luacheck: ignore\n')
for _, k in ipairs(sorted) do
f:write('\t"', k, '",\n')
end
f:write('}\n')
f:close()
end)