| 1 |
I still suggest you to make a real mod, it solves everything.
|
1 |
I still suggest you to make a real mod, it solves everything.
|
| 2 |
\n
|
2 |
\n
|
| 3 |
the process is :
|
3 |
the process is :
|
| 4 |
\n
|
4 |
\n
|
| 5 |
load unitdef files.
|
5 |
load unitdef files.
|
| 6 |
\n
|
6 |
\n
|
| 7 |
run tweakdefs.
|
7 |
run tweakdefs.
|
| 8 |
\n
|
8 |
\n
|
| 9 |
gen commander unitdefs.
|
9 |
gen commander unitdefs.
|
| 10 |
\n
|
10 |
\n
|
| 11 |
https://github.com/ZeroK-RTS/Zero-K/blob/master/gamedata/modularcomms/clonedefs.lua#L12 changed explodeAs.
|
11 |
https://github.com/ZeroK-RTS/Zero-K/blob/master/gamedata/modularcomms/clonedefs.lua#L12 changed explodeAs.
|
| 12 |
But it just changed high level and I didnt figure out why lv1 comm dont explode normally, .
|
12 |
But it just changed high level and I didnt figure out why lv1 comm dont explode normally, .
|
| 13 |
\n
|
13 |
\n
|
| 14 |
(
and
im
lazy
to
)
|
14 |
(
and
im
lazy
to
check)
|
| 15 |
\n
|
15 |
\n
|
| 16 |
you dont need to set weapon.
|
16 |
you dont need to set weapon.
|
| 17 |
\n
|
17 |
\n
|
| 18 |
If you really want to make tweakdefs, you can look https://zero-k.info/Mods/Detail/94 's code, which hacks Spring.Echo to do op things.
|
18 |
If you really want to make tweakdefs, you can look https://zero-k.info/Mods/Detail/94 's code, which hacks Spring.Echo to do op things.
|
| 19 |
\n
|
19 |
\n
|
| 20 |
Btw you can have a widget
|
20 |
Btw you can have a widget
|
| 21 |
[spoiler]
|
21 |
[spoiler]
|
| 22 |
{{{
|
22 |
{{{
|
| 23 |
function widget:GetInfo()
|
23 |
function widget:GetInfo()
|
| 24 |
return {
|
24 |
return {
|
| 25 |
name = "run lua code",
|
25 |
name = "run lua code",
|
| 26 |
desc = "run lua code when in game",
|
26 |
desc = "run lua code when in game",
|
| 27 |
author = "XNT",
|
27 |
author = "XNT",
|
| 28 |
date = "date",
|
28 |
date = "date",
|
| 29 |
license = "",
|
29 |
license = "",
|
| 30 |
layer = 0,
|
30 |
layer = 0,
|
| 31 |
enabled = true,
|
31 |
enabled = true,
|
| 32 |
}
|
32 |
}
|
| 33 |
end
|
33 |
end
|
| 34 |
\n
|
34 |
\n
|
| 35 |
\n
|
35 |
\n
|
| 36 |
_G=getfenv()
|
36 |
_G=getfenv()
|
| 37 |
\n
|
37 |
\n
|
| 38 |
local Chili
|
38 |
local Chili
|
| 39 |
\n
|
39 |
\n
|
| 40 |
local Screen0
|
40 |
local Screen0
|
| 41 |
\n
|
41 |
\n
|
| 42 |
local ChWindow
|
42 |
local ChWindow
|
| 43 |
\n
|
43 |
\n
|
| 44 |
local MainWindow
|
44 |
local MainWindow
|
| 45 |
\n
|
45 |
\n
|
| 46 |
local fontSize = 12
|
46 |
local fontSize = 12
|
| 47 |
\n
|
47 |
\n
|
| 48 |
local ChLabel
|
48 |
local ChLabel
|
| 49 |
\n
|
49 |
\n
|
| 50 |
local ChEditBox
|
50 |
local ChEditBox
|
| 51 |
\n
|
51 |
\n
|
| 52 |
\n
|
52 |
\n
|
| 53 |
local EcoRatioCurLabel
|
53 |
local EcoRatioCurLabel
|
| 54 |
\n
|
54 |
\n
|
| 55 |
local codebox
|
55 |
local codebox
|
| 56 |
\n
|
56 |
\n
|
| 57 |
local resbox
|
57 |
local resbox
|
| 58 |
\n
|
58 |
\n
|
| 59 |
local runbutton
|
59 |
local runbutton
|
| 60 |
\n
|
60 |
\n
|
| 61 |
local function pack(...)
|
61 |
local function pack(...)
|
| 62 |
return select("#",...),{...}
|
62 |
return select("#",...),{...}
|
| 63 |
end
|
63 |
end
|
| 64 |
\n
|
64 |
\n
|
| 65 |
\n
|
65 |
\n
|
| 66 |
local function dostring(str)
|
66 |
local function dostring(str)
|
| 67 |
local f,err=loadstring(str)
|
67 |
local f,err=loadstring(str)
|
| 68 |
if not f then
|
68 |
if not f then
|
| 69 |
return -1,err
|
69 |
return -1,err
|
| 70 |
else
|
70 |
else
|
| 71 |
setfenv(f,_G)
|
71 |
setfenv(f,_G)
|
| 72 |
local suc,res1,res2=pcall(function ()
|
72 |
local suc,res1,res2=pcall(function ()
|
| 73 |
return pack(f())
|
73 |
return pack(f())
|
| 74 |
end)
|
74 |
end)
|
| 75 |
if not suc then
|
75 |
if not suc then
|
| 76 |
return -2,res1
|
76 |
return -2,res1
|
| 77 |
else
|
77 |
else
|
| 78 |
return res1,res2
|
78 |
return res1,res2
|
| 79 |
end
|
79 |
end
|
| 80 |
end
|
80 |
end
|
| 81 |
end
|
81 |
end
|
| 82 |
\n
|
82 |
\n
|
| 83 |
\n
|
83 |
\n
|
| 84 |
local function RunCode()
|
84 |
local function RunCode()
|
| 85 |
local code=codebox:GetText()
|
85 |
local code=codebox:GetText()
|
| 86 |
if code then
|
86 |
if code then
|
| 87 |
local result_str=""
|
87 |
local result_str=""
|
| 88 |
local c,res=dostring(code)
|
88 |
local c,res=dostring(code)
|
| 89 |
if c==-1 then
|
89 |
if c==-1 then
|
| 90 |
result_str="Failed to loadstring with error" .. res
|
90 |
result_str="Failed to loadstring with error" .. res
|
| 91 |
elseif c==-2 then
|
91 |
elseif c==-2 then
|
| 92 |
result_str="Failed to call with error" .. res
|
92 |
result_str="Failed to call with error" .. res
|
| 93 |
else
|
93 |
else
|
| 94 |
for i = 1, c do
|
94 |
for i = 1, c do
|
| 95 |
result_str=result_str .. tostring( res[i] ) .. "; "
|
95 |
result_str=result_str .. tostring( res[i] ) .. "; "
|
| 96 |
end
|
96 |
end
|
| 97 |
end
|
97 |
end
|
| 98 |
resbox:SetCaption(result_str)
|
98 |
resbox:SetCaption(result_str)
|
| 99 |
Spring.Echo(result_str)
|
99 |
Spring.Echo(result_str)
|
| 100 |
else
|
100 |
else
|
| 101 |
resbox:SetCaption("no code")
|
101 |
resbox:SetCaption("no code")
|
| 102 |
end
|
102 |
end
|
| 103 |
end
|
103 |
end
|
| 104 |
\n
|
104 |
\n
|
| 105 |
function widget:Initialize()
|
105 |
function widget:Initialize()
|
| 106 |
|
106 |
|
| 107 |
Chili=WG.Chili
|
107 |
Chili=WG.Chili
|
| 108 |
Screen0=Chili.Screen0
|
108 |
Screen0=Chili.Screen0
|
| 109 |
ChWindow=Chili.Window
|
109 |
ChWindow=Chili.Window
|
| 110 |
ChLabel=Chili.Label
|
110 |
ChLabel=Chili.Label
|
| 111 |
ChEditBox=Chili.EditBox
|
111 |
ChEditBox=Chili.EditBox
|
| 112 |
MainWindow=ChWindow:New{
|
112 |
MainWindow=ChWindow:New{
|
| 113 |
classname = "main_window_small_tall",
|
113 |
classname = "main_window_small_tall",
|
| 114 |
name = 'Lua Repl',
|
114 |
name = 'Lua Repl',
|
| 115 |
x = 50,
|
115 |
x = 50,
|
| 116 |
y = 150,
|
116 |
y = 150,
|
| 117 |
width = 500,
|
117 |
width = 500,
|
| 118 |
height = 80,
|
118 |
height = 80,
|
| 119 |
padding = {16, 8, 16, 8},
|
119 |
padding = {16, 8, 16, 8},
|
| 120 |
dockable = true,
|
120 |
dockable = true,
|
| 121 |
dockableSavePositionOnly = true,
|
121 |
dockableSavePositionOnly = true,
|
| 122 |
draggable = true,
|
122 |
draggable = true,
|
| 123 |
resizable = true,
|
123 |
resizable = true,
|
| 124 |
tweakResizable = true,
|
124 |
tweakResizable = true,
|
| 125 |
parent = Screen0,
|
125 |
parent = Screen0,
|
| 126 |
}
|
126 |
}
|
| 127 |
\n
|
127 |
\n
|
| 128 |
codebox=ChEditBox:New{
|
128 |
codebox=ChEditBox:New{
|
| 129 |
parent=MainWindow,
|
129 |
parent=MainWindow,
|
| 130 |
x = 8,
|
130 |
x = 8,
|
| 131 |
y = 8,
|
131 |
y = 8,
|
| 132 |
right=8,
|
132 |
right=8,
|
| 133 |
\n
|
133 |
\n
|
| 134 |
}
|
134 |
}
|
| 135 |
\n
|
135 |
\n
|
| 136 |
resbox=ChLabel:New{
|
136 |
resbox=ChLabel:New{
|
| 137 |
parent=MainWindow,
|
137 |
parent=MainWindow,
|
| 138 |
y=60,x=8,
|
138 |
y=60,x=8,
|
| 139 |
autosize=true,
|
139 |
autosize=true,
|
| 140 |
valign="top",
|
140 |
valign="top",
|
| 141 |
}
|
141 |
}
|
| 142 |
\n
|
142 |
\n
|
| 143 |
runbutton=Chili.Button:New{
|
143 |
runbutton=Chili.Button:New{
|
| 144 |
parent=MainWindow,
|
144 |
parent=MainWindow,
|
| 145 |
y=32,x=8,
|
145 |
y=32,x=8,
|
| 146 |
OnClick={RunCode}
|
146 |
OnClick={RunCode}
|
| 147 |
}
|
147 |
}
|
| 148 |
\n
|
148 |
\n
|
| 149 |
end
|
149 |
end
|
| 150 |
}}}
|
150 |
}}}
|
| 151 |
[/spoiler]
|
151 |
[/spoiler]
|