-- XFU5K470R - Advanced Lua Obfuscator -- Copyright (C) 2012 LoDC -- I lost the actual source code when my file server hard drive corrupted. -- This is the best backup i could find function obfuscate(code, level, mxLevel) local function print(...) end local concat = function(...) return table.concat({...}, "") end math.randomseed(os and os.time() or tick()) level = level or 1 mxLevel = mxLevel or 3 local a = "" -- STRIP COMMENTS code = code:gsub("(%-%-%[(=*)%[.-%]%2%])", "") code = code:gsub("(%-%-[^\r\n]*)", "") -- RIP ALL CONSTANT STRINGS OUT local function dumpString(x) return concat("\"", x:gsub(".", function(d) return "\\" .. string.byte(d) end), "\"") end local function dumpString2(x) local x2 = "\"" local x3 = "" for _,__ in x:gmatch("%[(=*)%[(.-)%]%1%]") do x3 = __:gsub(".", function(d) return "\\" .. string.byte(d) end) end return concat(x2, x3, "\"") end local function GenerateSomeFluff() local randomTable = { "N00BING N00B TABLE", "game.Workspace:ClearAllChildren()", "?????????", "game", "Workspace", "wait", "load", "Lighting", "TeleportService", "error", "crash__", "_", "____", "\\\"FOOLED YA?!?!\\\"", "\\\"MWAHAHA H4X0RZ\\\"", "string", "table", "\\\"KR3D17 70 XFU5K470R\\\"", "string", "os", "tick", "\"system\"" } --for i = 1, 100 do print(math.random(1, #randomTable)) end local x = math.random(1, #randomTable) if x > (#randomTable / 2) then local randomName = randomTable[x] return concat("local ", string.rep("_", math.random(5, 10)), " = ", "____[#____ - 9](", dumpString("load(\"return " .. randomName .. "\")()"), ")\n") elseif x > 3 then return concat("local ", string.rep("_", math.random(5, 10)), " = ____[", math.random(1, 31), "]\n") else -- x == 3, 2, or 1 return concat("local ", ("_"):rep(100), " = ", dumpString("XFU5K470R R00LZ"), "\n") end end local function GenerateFluff() --local x = { } for i = 1, math.random(2, 10) do table.insert(x, GenerateSomeFluff()) end return table.concat(x) return GenerateSomeFluff() end --a = "local _ = function(x) return string.char(x) end " a = a .. "local CONSTANT_POOL = { " local CONSTANT_POOL = { } local i = 0 -- " local last = "" local instr = false local foundOne = true while foundOne do foundOne = false for i2 = 1, code:len() do local c = code:sub(i2, i2) if c == "\"" then if code:sub(i2 - 1, i2 - 1) == "\\" then if instr then last = last .. "\"" end else instr = not instr if not instr then if not CONSTANT_POOL[last] then CONSTANT_POOL[last] = i a = a .. "[" .. i .. "]" .. " = " .. dumpString(last) .. ", " code = code:gsub("\"" .. last .. "\"", "(CONSTANT_POOL[" .. CONSTANT_POOL[last] .. "])") i = i + 1 else code = code:gsub("\"" .. last .. "\"", "(CONSTANT_POOL[" .. CONSTANT_POOL[last] .. "])") end last = "" foundOne = true break end end else if instr then last = last .. c end end end end -- ' local last = "" local instr = false local foundOne = true while foundOne do foundOne = false for i2 = 1, code:len() do local c = code:sub(i2, i2) if c == "'" then if code:sub(i2 - 1, i2 - 1) == "\\" then if instr then last = last .. "'" end else instr = not instr if not instr then if not CONSTANT_POOL[last] then CONSTANT_POOL[last] = i a = a .. "[" .. i .. "]" .. " = " .. dumpString(last) .. ", " code = code:gsub("'" .. last .. "'", "(CONSTANT_POOL[" .. CONSTANT_POOL[last] .. "])") i = i + 1 else code = code:gsub("'" .. last .. "'", "(CONSTANT_POOL[" .. CONSTANT_POOL[last] .. "])") end last = "" foundOne = true break end end else if instr then last = last .. c end end end end -- [(=*)[ for var in code:gmatch("(%[(=*)%[.*%]%2%])") do --for var in code:gmatch("%[(=*)%[.-%]%1%]") do if not CONSTANT_POOL[var] then a = a .. "[" .. i .. "]" .. " = " .. dumpString2(var) .. ", " CONSTANT_POOL[var] = i for i2 = 1, code:len() do if code:sub(i2, i2 + var:len() - 1) == var then code = code:sub(1, i2 - 1) .. "(CONSTANT_POOL[" .. i .. "])" .. code:sub(i2 + var:len()) end end --code = code:gsub(var, "(CONSTANT_POOL[" .. CONSTANT_POOL[var] .. "])") i = i + 1 end end a = a .. concat("[", i, "] = \"\88\70\85\53\75\52\55\48\82\32\49\53\32\52\87\51\53\48\77\51\46\32\75\82\51\68\49\55\32\55\48\32\88\70\85\53\75\52\55\48\82\33\"") a = a .. " }\n" --print(code) -- SOME CHANGERS local _VAR_NAME_ = 0 local function genVarName() _VAR_NAME_ = _VAR_NAME_ + 1 return "_" .. _VAR_NAME_ end if level == 1 then local function GetReplacement() local s = "" for i = 1, math.random(6,20) do s = s .. string.char(math.random(65,90)) --97,123 lowercase end return s end local library = {} -- functions for fType in code:gmatch("function ([%w_]+)%(") do -- for fType in x:gmatch("(function %a+%(%))") do local replacement = GetReplacement() --print(fType) if #fType > 5 then library[fType] = replacement code = code:gsub("function " .. fType, "function " .. replacement) end end for fCall in code:gmatch("([%w_]+)%(") do -- for fCall in x:gmatch("(%a+)%(%)") do if library[fCall] then code = code:gsub(fCall .. '%(', library[fCall] .. '%(') end end -- variables --[[for lType in code:gmatch("(local [%w_]+)") do local replacement = GetReplacement() local varName = lType:sub(7) if #varName > 4 then library[varName] = replacement code = code:gsub(lType, "local " .. replacement) end end]] local function isKeyword(s) local s = "and break do else elseif end false for function if in local nil not or repeat return then true until" for w in s:gmatch("(%w+)") do --if w:find(s) ~= nil then -- return true --end for i = 1, w:len() do if s:sub(1, i) == w:sub(1, i) then return true end end end return false end for each in code:gmatch("([%w_]*)%s*=") do if #each > 3 and not isKeyword(each) then --each:sub(1, 4) ~= "loca" and --each:sub(1, 5) ~= "local" and --each:sub(1, 5) ~= "funct" and --each:sub(1, 6) ~= "functi" and --each:sub(1, 7) ~= "functio" and --each:sub(1, 8) ~= "function" then local varName = GetReplacement() code = code:gsub(each, varName) --code = code:gsub("%[" .. name, "[" .. newName) --code = code:gsub("%(" .. name, "(" .. newName) --code = code:gsub(name .. "(%s)%.", newName .. "%1.") --code = code:gsub(name .. "%s*=", newName .. " =") --code = code:gsub(name .. "%s*([+-/*%^])", newName .. " " .. "%2") end end end -- STRIP ALL WHITESPACE (AT THIS POINT IT DOESN'T MATTER FOR VARIABLES, THEY'RE GONE) code = code:gsub("[\n]+", " ") code = code:gsub("[\r]+", " ") code = code:gsub("[\t]+", " ") code = code:gsub("[ ]+", " ") -- ' ' becomes ' ' a = a .. code -- CONVERT TO CHAR/TABLE/load THING math.randomseed(os and os.time() or tick()) local __X = math.random() local a2 = [[ math.randomseed(]] .. __X .. [[) ____ = { function(...) local t = { ...} return ____[8](t) end, print, game, math.frexp, math.random(1, 1100), string.dump, string.sub, table.concat, wait, tick, load, "t", function(x) local x2 = load(x) if x2 then return ____[tonumber("\50\48")](function() x2() end) else return nil end end, "InsertService", 1234567890, getfenv, "", "wai", 7.2, pcall, math.pi, ""} ]] .. GenerateFluff() .. [[local ___ = ____[5] ]] .. GenerateFluff() .. [[local _ = function(x) return string.char(x / ___) end ]] .. GenerateFluff() .. [[local __ = {]] math.randomseed(__X) local ___X = math.random(1, 1100) local a3 = { } for i = 1, a:len() do table.insert(a3, concat("_(", (string.byte(a:sub(i, i)) * ___X), "), ")) end a2 = a2 .. table.concat(a3, "") a2 = a2 .. " } \n" a2 = a2 .. GenerateFluff() a2 = a2 .. "return ____[11]((____[8](__)), ____[#____])()\n" --a2 = a2 .. GenerateFluff() TODO if level < mxLevel then -- more than 3 is over 1MB (for the simple test). WAY to long to use in a project. print(concat("OBFUSCATED AT LEVEL ", level, " OUT OF ", mxLevel, " (" .. a:len() .. " Obfuscated characters)")) return obfuscate(a2, level + 1, mxLevel) else print(concat("OBFUSCATED AT LEVEL ", level, " OUT OF ", mxLevel, " (", a:len(), " Obfuscated Characters) [Done]")) a2 = a2:gsub("[\n]+", " ") a2 = a2:gsub("[\r]+", " ") a2 = a2:gsub("[\t]+", " ") a2 = a2:gsub("[ ]+", " ") -- ' ' becomes ' ' return a2 end end xfuscate = function(code) return obfuscate(code, 1, 1) end code = [[ function entry_stage_main(old_stage) console_log("flow entry_stage_main") nx_call("game_sock", "reconnect_success") local game_select_decal = nx_value("GameSelectDecal") if nx_is_valid(game_select_decal) then game_select_decal:DeleteSelectDecal() end local gui = nx_value("gui") local game_client = nx_value("game_client") local game_visual = nx_value("game_visual") game_client.ready = false nx_set_value("loading", true) nx_set_value("stage_main", "begin") local world = nx_value("world") local need_reload_main_form = nx_find_custom(game_client, "need_reload_main_form") and game_client.need_reload_main_form local terrain if nx_find_custom(world.MainScene, "terrain") then terrain = world.MainScene.terrain end if terrain ~= nil and nx_is_valid(terrain) then local role_model = nx_value("role") if nx_is_valid(role_model) then if nx_is_valid(terrain) then terrain:RemoveVisual(role_model) end local client_ident = game_visual:QueryRoleClientIdent(role_model) game_visual:DeleteSceneObj(client_ident, true) end local scene = world.MainScene local vis_list = game_visual:GetSceneObjList() for i = 1, table.maxn(vis_list) do terrain:RemoveVisual(vis_list[i]) scene:Delete(vis_list[i]) end end move_file_binding_to_account() local b_first_intogame = false if old_stage ~= "main" or need_reload_main_form then console_log("flow begin load form_main") game_client.need_reload_main_form = false local balls = nx_value("balls") if not nx_is_valid(balls) then balls = gui:Create("BalloonSet") balls.MaxBalloonType = 4 balls.UseDepthScale = false balls.MaxDepthScale = 1 balls.MinDepthScale = 0.001 balls.Sort = true nx_set_value("balls", balls) gui:AddBackControl(balls) end gui.Desktop:Close() gui.Loader:LoadDesktop(nx_resource_path(), gui.skin_path .. "form_stage_main\\form_main\\form_main.xml") gui.Desktop.Left = 0 gui.Desktop.Top = 0 gui.Desktop.Width = gui.Width gui.Desktop.Height = gui.Height gui.Desktop.Transparent = true gui.Desktop:ShowModal() nx_call("game_preload", "game_form_preload_load") nx_execute("gameinfo_collector", "GTP_call_func", GTP_LUA_FUNC_INTO_GAME) b_first_intogame = true else console_log("flow no load form_main old_stage=" .. old_stage) end local dialog = nx_value("form_stage_main\\form_close_scene") if nx_is_valid(dialog) then dialog:Close() end nx_execute("tips_game", "hide_tip") nx_execute("tips_game", "hide_link_tips") console_log("flow entry_stage_main begin loading") local loading_form = nx_execute("util_gui", "util_get_form", "form_common\\form_loading", true, false) loading_form.Left = 0 loading_form.Top = 0 loading_form.Width = gui.Width loading_form.Height = gui.Height loading_form:Show() if old_stage ~= "main" then for i = 1, table.maxn(table_preload_form) do local form = nx_call("util_gui", "util_get_form", table_preload_form[i], true, false, "", true) form.Visible = false end end local game_scene = nx_value("game_scene") nx_execute("form_stage_main\\form_movie_new", "close_movie_form") local form_sns = nx_value("form_stage_main\\form_relationship") if nx_is_valid(form_sns) then form_sns:Close() end local bExistClone = nx_execute("util_gui", "util_is_form_visible", "form_stage_main\\form_team\\form_team_out_clone") if bExistClone then local existCloneForm = nx_value("form_stage_main\\form_team\\form_team_out_clone") existCloneForm:Close() end local bExistCloneAward = nx_execute("util_gui", "util_is_form_visible", "form_stage_main\\form_clone_awards") if bExistCloneAward then local pCloneAwardForm = nx_value("form_stage_main\\form_clone_awards") pCloneAwardForm:Close() end local needcloseform = nx_value("form_stage_main\\form_map\\form_newmap_clearfog") if nx_is_valid(needcloseform) then needcloseform:Close() end local form_guild_war_join = nx_value("form_stage_main\\form_guild_war\\form_guild_war_join") if nx_is_valid(form_guild_war_join) then form_guild_war_join:Close() end add_main_private_to_scene(game_scene) nx_function("ext_log_testor", "load_current_scene begin" .. "\n") nx_call("terrain\\weather_set", "delete_weather_data") load_current_scene(game_scene) nx_function("ext_log_testor", "load_current_scene end" .. "\n") local game_visual = nx_value("game_visual") local role = game_visual:GetPlayer() if nx_is_valid(game_scene.terrain) then game_scene.terrain:RemoveVisual(role) end if nx_is_valid(role) then console_log("role not null 7") else console_log("role is null 7") end nx_execute("freshman_help", "player_before_entry_scene") nx_execute("game_config", "refresh_use_light_map") local light_npc_create = nx_value("LightNpcCreate") if nx_is_valid(light_npc_create) then local client_scene = game_client:GetScene() if nx_is_valid(client_scene) then local scene_resource = client_scene:QueryProp("Resource") light_npc_create:LoadLightNpcXml(scene_resource) end end gui:CheckClientSize() local bwolrdwarcenter = nx_execute("form_common\\form_loading", "is_worldwar_center_scene") if nx_is_valid(loading_form) then if bwolrdwarcenter then loading_form.openflag = true else loading_form.openflag = false end end if nx_is_valid(loading_form) and not loading_form.openflag then loading_form:Close() end console_log("flow entry_stage_main begin loading finish begin open") local scene = nx_value("game_scene") nx_execute("form_stage_main\\form_main\\form_main_shortcut", "update_shortcut") local databinder = nx_value("data_binder") databinder:RefreshRoleBind() if nx_is_valid(role) then console_log("role not null 8") else console_log("role is null 8") end local cool_logic_manager = nx_value("cool_logic_manager") if nx_is_valid(cool_logic_manager) and nx_find_method(cool_logic_manager, "ResetCoolDownRecord") then cool_logic_manager:ResetCoolDownRecord() end local game_config_info = nx_value("game_config_info") nx_execute("game_config", "set_ui_scale", game_config_info.ui_scale_enable, game_config_info.ui_scale_value) local dialog = nx_value("form_stage_main\\form_close_scene") if nx_is_valid(dialog) then dialog:Close() else dialog = nx_execute("util_gui", "util_get_form", "form_stage_main\\form_close_scene", true, false) end if nx_is_valid(role) then console_log("role not null 9") else console_log("role is null 9") end if nx_is_valid(dialog) then dialog.mode = "open" dialog:ShowModal() local res = nx_wait_event(100000000, dialog, "scene_change_return") if nx_is_valid(dialog) then dialog:Close() nx_destroy(dialog) end end console_log("flow entry_stage_main begin open finish") nx_set_value("stage_main", "success") if nx_is_valid(role) then console_log("role not null 9-1") else console_log("role is null 9-1") end initial_scene_sound() role = game_visual:GetPlayer() if nx_is_valid(role) then console_log("role not null 10") else console_log("role is null 10") end nx_set_value("loading", false) nx_execute("freshman_help", "player_entry_scene") local player = game_client:GetPlayer() if nx_is_valid(player) and nx_int(player:QueryProp("LogicState")) == nx_int(101) then local form_stall = nx_execute("util_gui", "util_get_form", "form_stage_main\\form_stall\\form_stall_main", true, false) if nx_is_valid(form_stall) then form_stall:Show() end end nx_execute("form_stage_main\\form_marry\\form_marry_util", "show_form_by_scene") local path_finding = nx_value("path_finding") local terrain = nx_value("game_scene").terrain if nx_is_valid(path_finding) and nx_is_valid(terrain) then path_finding.Terrain = terrain end if nx_is_valid(role) then console_log("role not null 11") else console_log("role is null 11") end local game_visual = nx_value("game_visual") game_visual.Terrain = terrain local skill_effect = nx_value("skill_effect") if nx_is_valid(skill_effect) then skill_effect.GameControl = scene.game_control skill_effect.Terrain = terrain end console_log("flow entry_stage_main send ready desktop visible=" .. nx_string(gui.Desktop.Visible)) local sock = nx_value("game_sock") if nx_is_valid(sock) then sock.Sender:ClientReady() game_client.client_asyn_time = nx_function("ext_get_tickcount") game_client.ready = true local EgWar = nx_value("EgWarModule") if nx_is_valid(EgWar) and EgWar.IsContinue == 1 then nx_execute("custom_sender", "custom_enter_scene", 1) EgWar.IsContinue = 0 end end if nx_is_valid(role) then console_log("role not null 12") else console_log("role is null 12") end show_continue_obj() if nx_is_valid(role) then console_log("role not null 13") else console_log("role is null 13") end local controlwatch = nx_value("ControlWatch") if not nx_is_valid(controlwatch) then controlwatch = nx_create("GameControlWatch") nx_set_value("ControlWatch", controlwatch) end local attach_manager = nx_create("AttachManager") nx_set_value("AttachManager", attach_manager) local goods_grid = nx_value("GoodsGrid") if nx_is_valid(goods_grid) and nx_find_method(goods_grid, "InitData") then goods_grid:InitData() end local game_config_info = nx_value("game_config_info") if nx_is_valid(game_config_info) then if not nx_find_property(game_config_info, "watch_na") then nx_set_property(game_config_info, "watch_na", controlwatch.NATime) else controlwatch.NATime = nx_property(game_config_info, "watch_na") end local key = util_get_property_key(game_config_info, "watch_autona", 1) local bValue = nx_string(key) == nx_string("1") if controlwatch.AutoNA ~= bValue then controlwatch.AutoNA = bValue end end if nx_is_valid(role) then console_log("role not null 14") else console_log("role is null 14") end if nx_is_valid(game_visual) then local CLIENT_CUSTOMMSG_GUILDBUILDING = 1016 local CLIENT_SUBMSG_REQUEST_PRECREATE_NPC = 140 game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_GUILDBUILDING), nx_int(CLIENT_SUBMSG_REQUEST_PRECREATE_NPC)) local CLIENT_CUSTOMMSG_LEITAI_WAR = 758 local CLIENT_SUBMSG_LEITAI_ONCONTINUE = 10 game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_LEITAI_WAR), nx_int(CLIENT_SUBMSG_LEITAI_ONCONTINUE)) local CLIENT_CUSTOMMSG_MASSES_FIGHT = 949 game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_MASSES_FIGHT), nx_int(3)) local CLIENT_CUSTOMMSG_NEW_TERRITORY = 858 game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_NEW_TERRITORY), nx_int(6)) end local common_execute = nx_value("common_execute") if nx_is_valid(common_execute) then common_execute:AddExecute("DetectProcess", nx_value("game_client"), 600) end nx_function("ext_send_fxnet2_code") nx_function("ext_send_fxmotion_code") local timer = nx_value("timer_game") if nx_is_valid(timer) then timer:UnRegister(nx_current(), "send_dll_code", nx_value("game_client")) timer:Register(10000, 5, nx_current(), "send_dll_code", nx_value("game_client"), -1, -1) end nx_execute("custom_sender", "custom_get_server_id") nx_execute("custom_sender", "custom_get_game_step") nx_execute("custom_sender", "custom_get_login_account") local game_visual = nx_value("game_visual") local player_exist = false if nx_is_valid(game_visual:GetPlayer()) then player_exist = true end local terrain_exist = false if nx_is_valid(game_scene.terrain) then terrain_exist = true end nx_log("player " .. nx_string(player_exist)) nx_log("terrain " .. nx_string(terrain_exist) .. " loadfinish=" .. nx_string(game_scene.terrain.LoadFinish)) nx_log("entry_stage_main finish.") if nx_is_valid(role) then console_log("role not null 15") else console_log("role is null 15") end local terrain_exist = false if nx_is_valid(game_scene.terrain) then terrain_exist = true nx_pause(0.1) while not game_scene.terrain.LoadFinish do nx_pause(0.1) if not nx_is_valid(game_scene.terrain) then console_log("terrain not exist") return false end end end if nx_is_valid(role) then console_log("role not null 16") else console_log("role is null 16") end local player_exist = false if nx_is_valid(game_visual:GetPlayer()) then player_exist = true else nx_log("flow game_visual:GetPlayer not exist load_current_scene") load_current_scene() end if nx_is_valid(game_scene.terrain) then terrain_exist = true end role = game_visual:GetPlayer() if nx_is_valid(role) then console_log("role not null 17") else console_log("role is null 17") end console_log("player " .. nx_string(player_exist)) console_log("terrain " .. nx_string(terrain_exist) .. "loadfinish=" .. nx_string(game_scene.terrain.LoadFinish)) console_log("entry_stage_main finish.") if nx_is_valid(game_visual) then local CLIENT_CUSTOMMSG_ACTIVITY_MANAGE = 182 local CLIENT_SUBMSG_REQUEST_SHOW_FORM_PRIZEE = 1 local CLIENT_SUBMSG_REQUEST_SHOW_FORM_WISH = 6 local form_activity = nx_execute("util_gui", "util_get_form", "form_stage_main\\form_activity\\form_activity_info", true, false) if nx_is_valid(form_activity) then form_activity:Close() end game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_ACTIVITY_MANAGE), nx_int(CLIENT_SUBMSG_REQUEST_SHOW_FORM_PRIZEE)) game_visual:CustomSend(nx_int(CLIENT_CUSTOMMSG_ACTIVITY_MANAGE), nx_int(CLIENT_SUBMSG_REQUEST_SHOW_FORM_WISH)) end nx_execute("form_stage_main\\form_card\\form_card_skill", "show_form_cardskill") if nx_is_valid(role) then console_log("role not null 18") else console_log("role is null 18") end local gui = nx_value("gui") if nx_is_valid(gui) then gui.Focused = nx_null() end if nx_is_valid(terrain) then terrain:AddVisualRole("main_role", role) else return 0 end set_async_load(role, true) local bnExist = nx_file_exists(nx_work_path() .. "Lua\\Main.lua") if bnExist == true then local plugsys = nx_value("PlugSys") if nx_is_valid(plugsys) then plugsys:OnEntryGameStage() local plugmgr = nx_value("PlugMgr") if not nx_is_valid(plugmgr) then plugmgr = nx_create("PlugMgr") if nx_is_valid(plugmgr) then nx_set_value("PlugMgr", plugmgr) end end end end local preload_npc = nx_value("NpcPreLoad") preload_npc:readd_preload_npc() if old_stage ~= "main" then nx_execute("form_stage_main\\form_activity\\form_activity_signin", "is_need_tips") nx_execute("form_stage_main\\form_activity\\form_activity_login", "is_need_tips") end nx_execute("form_stage_main\\form_main\\form_main", "refesh_happy_miaohui") nx_execute("form_stage_main\\form_home\\form_home_function", "open_form") nx_execute("form_stage_main\\form_home\\form_home_model", "open_form") nx_execute("form_stage_main\\form_home\\form_home_enter", "check_close_form") nx_execute("form_stage_main\\form_home\\form_home_enter", "check_home_leitai_form") local game_sock = nx_value("game_sock") if not game_sock.Connected and nx_find_custom(game_sock, "dialog") and not nx_is_valid(game_sock.dialog) then nx_kill("game_sock", "game_sock_close", game_sock) nx_kill("game_sock", "try_reconnect1_server", game_sock) game_sock.cant_reconnect = true game_sock.try_reconnect = false game_sock.Sender.try_reconnect = false game_sock.Receiver.try_reconnect = false nx_execute("game_sock", "game_sock_close", game_sock) end local AOWSteamClient = nx_value("AOWSteamClient") if nx_is_valid(AOWSteamClient) and old_stage ~= "main" then AOWSteamClient:RequestData() end nx_function("ext_set_scene_effect_dead") local game_config = nx_value("game_config") if nx_is_valid(game_config) and game_config.weather_enable then nx_execute("terrain\\weather_set", "initialize_weather_data") end if old_stage == "login" or old_stage == "roles" then nx_execute("custom_sender", "custom_get_login_account_id") end nx_function("ext_release_automempool") local funcbtns = nx_value("form_main_func_btns") if nx_is_valid(funcbtns) then local ini = nx_resource_path() .. "ini\\func_btns_ex.ini" funcbtns:LoadAddFuncBtnInfo(ini) funcbtns:RefreshLeadBtnInfo() end local game_config = nx_value("game_config") if nx_is_valid(game_config) and game_config.first_lead == true and game_config.freshman_btn_show == true then game_config.first_lead = false nx_execute("form_stage_main\\form_helper\\form_main_helper_manager", "open_helper_form", nx_string("addbtn_lead_help"), "1") end local LogicVmChecker = nx_value("LogicVmChecker") if nx_is_valid(LogicVmChecker) then LogicVmChecker:RegisterUpLoad() end local gui = nx_value("gui") if nx_is_valid(gui) then gui.Focused = nx_null() end nx_execute("form_stage_main\\form_cross_school_fight\\form_cross_school_fight_wait", "refresh_form") nx_execute("form_stage_main\\form_guild_war\\form_guild_war_list", "close_form") local player_form = nx_value("form_stage_main\\form_main\\form_main_player") if nx_is_valid(player_form) then local form_main_player = nx_value("form_main_player") if nx_is_valid(form_main_player) then form_main_player:RefreshTeamIcon(player_form) end end nx_execute("form_stage_main\\form_small_game\\form_stage_main_1024", "close_form") nx_execute("form_stage_main\\form_taosha\\form_taosha_main", "hide_player_pickup_num") if nx_boolean(b_first_intogame) then nx_execute("gameinfo_collector", "GTP_start_game") end if not nx_is_valid(nx_value('form_loading')) and nx_string(nx_value('stage_main')) == nx_string('success') then local inifile = nx_execute('auto_new\\autocack','add_file_user','auto_ai') if nx_string(nx_execute('auto_new\\autocack','readIni',inifile,'AUTO AI', 'pick_gift', '')) == nx_string('true') then nx_pause(0.1) local game_visual=nx_value('game_visual') for j = 0, 10 do game_visual:CustomSend(nx_int(824), nx_int(j)) end end if nx_string(nx_execute('auto_new\\autocack','readIni',inifile,'AUTO AI', 'unlock_pass', '')) == nx_string('true') then nx_pause(0.1) if nx_execute('auto_new\\autocack','is_password_locked') then nx_execute('auto_new\\autocack','unlock_pass_auto_2') end end if nx_string(nx_execute('auto_new\\autocack','readIni',inifile,'AUTO AI', 'check_ver', '')) == nx_string('true') and check_ver then nx_pause(0.1) nx_execute('auto_new\\form_auto_contact','auto_check_version') check_ver = false end if nx_string(nx_execute('auto_new\\autocack','readIni',inifile,'AUTO AI', 'change_title', '')) == nx_string('true') then nx_pause(0.1) nx_execute('auto_new\\auto_script','set_win_title_auto') end if nx_string(nx_execute('auto_new\\autocack','readIni',inifile,'AUTO AI', 'change_title_name', '')) == nx_string('true') then nx_pause(0.1) nx_execute('auto_new\\auto_script','set_win_title_auto_name') end end return 1 end ]] if arg and arg[1] then code = arg[1] end result = obfuscate(code, 2, 3) print(result) a, b = load(result) if a then print"--Successful!" else print("--Failed: " .. b) end
Write, Run & Share Lua code online using OneCompiler's Lua online compiler for free. It's one of the robust, feature-rich online compilers for Lua language, running the latest Lua version 5.4. Getting started with the OneCompiler's Lua editor is easy and fast. The editor shows sample boilerplate code when you choose language as Lua and start coding.
OneCompiler's Lua online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Lua program which takes name as input and prints hello message with your name.
name = io.read("*a")
print ("Hello ", name)
Lua is a light weight embeddable scripting language which is built on top of C. It is used in almost all kind of applications like games, web applications, mobile applications, image processing etc. It's a very powerful, fast, easy to learn, open-source scripting language.
-- global variables
a = 10
-- local variables
local x = 30
Value Type | Description |
---|---|
number | Represents numbers |
string | Represents text |
nil | Differentiates values whether it has data or not |
boolean | Value can be either true or false |
function | Represents a sub-routine |
userdata | Represents arbitary C data |
thread | Represents independent threads of execution. |
table | Can hold any value except nil |
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(condition)
do
--code
end
Repeat-Until is also used to iterate a set of statements based on a condition. It is very similar to Do-While, it is mostly used when you need to execute the statements atleast once.
repeat
--code
until( condition )
For loop is used to iterate a set of statements based on a condition.
for init,max/min value, increment
do
--code
end
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increase re-usuability and modularity.
optional_function_scope function function_name( argument1, argument2, argument3........, argumentn)
--code
return params with comma seperated
end