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/22/2024 9:52:56 AMAUrankSmokeDragon before revert after revert
Before After
1 i asked ai and it said this: 1 i asked ai and it said this:
2 \n 2 \n
3 To modify the pylonrange field within the customParams associative array of each element in the UnitDefs associative array, you can use a loop to iterate through the elements and update the value. Here’s how you can achieve this in Lua: 3 To modify the pylonrange field within the customParams associative array of each element in the UnitDefs associative array, you can use a loop to iterate through the elements and update the value. Here’s how you can achieve this in Lua:
4 \n 4 \n
5 Lua 5 Lua
6 \n 6 \n
7 for name, ud in pairs(UnitDefs) do 7 for name, ud in pairs(UnitDefs) do
8 if ud.customParams and ud.customParams.pylonrange then 8 if ud.customParams and ud.customParams.pylonrange then
9 ud.customParams.pylonrange = ud.customParams.pylonrange * 4 9 ud.customParams.pylonrange = ud.customParams.pylonrange * 4
10 end 10 end
11 end 11 end
12 \n 12 \n
13 AI-generated code. Review and use carefully. More info on FAQ. 13 AI-generated code. Review and use carefully. More info on FAQ.
14 In this code: 14 In this code:
15 \n 15 \n
16 We iterate over each element in the UnitDefs associative array using pairs. 16 We iterate over each element in the UnitDefs associative array using pairs.
17 We check if ud.customParams exists and if pylonrange is defined within it. 17 We check if ud.customParams exists and if pylonrange is defined within it.
18 If both conditions are met, we multiply the existing pylonrange value by 4. 18 If both conditions are met, we multiply the existing pylonrange value by 4.
19 \n
20 this does not work.. so maybe im confused and i dont know how to proceed
21 \n
22 can somone give me some code that works please?