⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmd_doline.lua

📁 这是整套横扫千军3D版游戏的源码
💻 LUA
字号:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------  file:    cmd_doline.lua--  brief:   adds a command to run raw LUA commands from the game console--  author:  Dave Rodgers----  Copyright (C) 2007.--  Licensed under the terms of the GNU GPL, v2 or later.------------------------------------------------------------------------------------------------------------------------------------------------------------------function widget:GetInfo()  return {    name      = "DoLine",    desc      = "Adds '/luaui <run|echo> ...' to run lua commands  (for devs)",    author    = "trepan",    date      = "Jan 8, 2007",    license   = "GNU GPL, v2 or later",    layer     = 0,    enabled   = true  --  loaded by default?  }end-------------------------------------------------------------------------------------------------------------------------------------------------------------------- Low level LUA access--local function RunCmd(cmd, optLine)  print(optLine)  local chunk, err = loadstring(optLine, 'run')  if (chunk == nil) then    print('doline error: ' .. err)  else    local success, err = pcall(chunk)    if (not success) then      Spring.Echo(err)    end	  end  return trueendlocal function EchoCmd(cmd, optLine)  local chunk, err = loadstring("return " .. optLine, 'echo')  if (chunk == nil) then    print('doline error: ' .. err)  else    local results = { pcall(chunk) }    local success = results[1]    if (not success) then      Spring.Echo(results[2])    else      table.remove(results, 1)      Spring.Echo(unpack(results))    end  end  return trueendfunction widget:Initialize()  widgetHandler:AddAction("doline",  RunCmd)  -- backwards compatible  widgetHandler:AddAction("run",     RunCmd)  widgetHandler:AddAction("echolua", EchoCmd, nil)  widgetHandler:AddAction("echo",    EchoCmd, nil, "t") -- text only  -- NOTE: that last entry is text only so that we do not  --       override the default "/echo" Spring command when  --       it is bound to a keyset.end--------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -