我有多个Steam帐户,我想通过一个带有我指定的选项的Lua脚本启动这些帐户。除了用提供的代码启动之外,我已经把所有的事情都整理好了。我不知道如何“传递”这种格式的变量。
function Steam(n, opt1, opt2, opt3)
os.execute[["start C:\Program" "Files\Sandboxie\Start.exe /box:Steam2 D:\Steam\steam.exe -login username password -opt1 -opt2 -opt3"]]
end我设置了我的用户名和沙箱,这样只需要用相同的密码更改号码(fenriros2,fenriros3,Steam2,Steam3等)。
基本上,我想要这个;
Steam(3, -tf, -exit, -textmode)待办事项;
os.execute[["start C:\Program" "Files\Sandboxie\Start.exe /box:Steam3 D:\Steam\steam.exe -login fenriros3 password -applaunch 440 -textmode"]]完成后,我将使用-exit关闭lua窗口。
我知道我的代码效率不是很高,但这是以后的担忧。现在我只需要让它正常工作。
任何帮助都是非常感谢的,如果我错过了一些明显的东西,我道歉,我在Lua仍然是相当新的。
发布于 2013-03-26 16:10:56
第一个显而易见的问题。[]分隔一个字符串,因此您需要做的就是为该字符串创建一个变量,并根据需要替换内容。
function Steam(n, opt1, opt2, opt3)
-- Set up execute string with placeholders for the parameters.
local strExecute = [["start C:\Program" "Files\Sandboxie\Start.exe /box:Steam{n} D:\Steam\steam.exe -login fenriros{n} password -{opt1} -{opt2} -{opt3}"]]
-- Use gsub to replace the parameters
-- You could just concat the string but I find it easier to work this way.
strExecute = strExecute:gsub('{n}',n)
strExecute = strExecute:gsub('{opt1}',opt1:gsub('%%','%%%%'))
strExecute = strExecute:gsub('{opt2}',opt2:gsub('%%','%%%%'))
strExecute = strExecute:gsub('{opt3}',opt3:gsub('%%','%%%%'))
os.execute(strExecute)
end
Steam(1,'r1','r2','r3')https://stackoverflow.com/questions/15630279
复制相似问题