Loading...
  OR  Zero-K Name:    Password:   

Post edit history

learning to code

To display differences between versions, select one or more edits in the list using checkboxes and click "diff selected"
Post edit history
Date Editor Before After
2/17/2024 1:20:53 AMunknownrankShaman before revert after revert
2/17/2024 1:20:26 AMunknownrankShaman before revert after revert
Before After
1 [q] 1 The solution here is:
2 for i = 1, #UnitDefs do 2 for i = 1, #UnitDefs do
3 local customParams = UnitDefs[i].customParams 3 local customParams = UnitDefs[i].customParams
4 if customParams.pylonrange then customParams.pylonrange = tostring(tonumber(customParams.pylonrange) * 4) end 4 if customParams.pylonrange then customParams.pylonrange = tostring(tonumber(customParams.pylonrange) * 4) end
5 end 5 end
6 [/q] 6
7 \n 7 \n
8 UnitDefs is an ordered table so you can use a for i = 1, #table iterator instead. One hang up you may have when analyzing this code is that lua tables are pointers to tables in memory (or.. something like that) so as long as the table exists, referencing it will alter the original table instead of the copy of the table. Mostly the "local customParams" here is done for readability, though it can have some speed up properties. The second part of this is this weird if-then statement here. What this is saying is "if this variable is not nil (not set) then do this". The only time pylonrange will not be nil is if it is used for range of the pylon, which is exactly what you're trying to alter. 8 UnitDefs is an ordered table so you can use a for i = 1, #table iterator instead. One hang up you may have when analyzing this code is that lua tables are pointers to tables in memory (or.. something like that) so as long as the table exists, referencing it will alter the original table instead of the copy of the table. Mostly the "local customParams" here is done for readability, though it can have some speed up properties. The second part of this is this weird if-then statement here. What this is saying is "if this variable is not nil (not set) then do this". The only time pylonrange will not be nil is if it is used for range of the pylon, which is exactly what you're trying to alter.
9 \n 9 \n
10 I suggest joining #modding and asking questions there or dming me. And please, do not post requests for help containing things like 10 I suggest joining #modding and asking questions there or dming me. And please, do not post requests for help containing things like
11 \n 11 \n
12 [q]and if you will not help me then delete my account so i can never return[/q] 12 [q]and if you will not help me then delete my account so i can never return[/q]
13 \n 13 \n
14 This is just bad behavior and I do not want to see these kinds of things as I think they reflect poorly on us as a community. I get coding is frustrating, but you need to hold your composure and approach coding like it's a puzzle. You ever play something like Factorio or the Zacktronics games? Something like that. I'm willing to tutor if you want it or I can stream some of my dev work I do around here. 14 This is just bad behavior and I do not want to see these kinds of things as I think they reflect poorly on us as a community. I get coding is frustrating, but you need to hold your composure and approach coding like it's a puzzle. You ever play something like Factorio or the Zacktronics games? Something like that. I'm willing to tutor if you want it or I can stream some of my dev work I do around here.