1 |
i now have the know how to complete this project. starting work.
|
1 |
i now have the know how to complete this project. starting work.
|
2 |
\n
|
2 |
\n
|
3 |
here is a look at my revised code doing the same thing as above:
|
3 |
here is a look at my revised code doing the same thing as above:
|
4 |
\n
|
4 |
\n
|
5 |
[spoiler]
|
5 |
[spoiler]
|
6 |
|
6 |
{
{
{
|
7 |
local highestmetalcost = 0
|
7 |
local highestmetalcost = 0
|
8 |
local lowestmetalcost = math.huge
|
8 |
local lowestmetalcost = math.huge
|
9 |
local validUnitNames = {
|
9 |
local validUnitNames = {
|
10 |
["Glaive"] = true, ["Ronin"] = true, ["Reaver"] = true, ["Knight"] = true,
|
10 |
["Glaive"] = true, ["Ronin"] = true, ["Reaver"] = true, ["Knight"] = true,
|
11 |
["Sling"] = true, ["Scythe"] = true, ["Phantom"] = true, ["Imp"] = true,
|
11 |
["Sling"] = true, ["Scythe"] = true, ["Phantom"] = true, ["Imp"] = true,
|
12 |
["Bandit"] = true, ["Rogue"] = true, ["Outlaw"] = true, ["Thug"] = true,
|
12 |
["Bandit"] = true, ["Rogue"] = true, ["Outlaw"] = true, ["Thug"] = true,
|
13 |
["Racketeer"] = true, ["Dirtbag"] = true, ["Felon"] = true, ["Snitch"] = true,
|
13 |
["Racketeer"] = true, ["Dirtbag"] = true, ["Felon"] = true, ["Snitch"] = true,
|
14 |
["Scorcher"] = true, ["Fencer"] = true, ["Ripper"] = true, ["Ravager"] = true,
|
14 |
["Scorcher"] = true, ["Fencer"] = true, ["Ripper"] = true, ["Ravager"] = true,
|
15 |
["Badger"] = true, ["Dart"] = true, ["Impaler"] = true, ["Dominatrix"] = true,
|
15 |
["Badger"] = true, ["Dart"] = true, ["Impaler"] = true, ["Dominatrix"] = true,
|
16 |
["Dagger"] = true, ["Scalpel"] = true, ["Mace"] = true, ["Halberd"] = true,
|
16 |
["Dagger"] = true, ["Scalpel"] = true, ["Mace"] = true, ["Halberd"] = true,
|
17 |
["Lance"] = true, ["Bolas"] = true, ["Claymore"] = true, ["Locust"] = true,
|
17 |
["Lance"] = true, ["Bolas"] = true, ["Claymore"] = true, ["Locust"] = true,
|
18 |
["Harpy"] = true, ["Blastwing"] = true, ["Revenant"] = true, ["Nimbus"] = true,
|
18 |
["Harpy"] = true, ["Blastwing"] = true, ["Revenant"] = true, ["Nimbus"] = true,
|
19 |
["Gnat"] = true, ["Krow"] = true, ["Charon"] = true, ["Hercules"] = true,
|
19 |
["Gnat"] = true, ["Krow"] = true, ["Charon"] = true, ["Hercules"] = true,
|
20 |
["Swift"] = true, ["Phoenix"] = true, ["Raven"] = true, ["Sparrow"] = true,
|
20 |
["Swift"] = true, ["Phoenix"] = true, ["Raven"] = true, ["Sparrow"] = true,
|
21 |
["Likho"] = true, ["Thunderbird"] = true, ["Owl"] = true, ["Flea"] = true,
|
21 |
["Likho"] = true, ["Thunderbird"] = true, ["Owl"] = true, ["Flea"] = true,
|
22 |
["Recluse"] = true, ["Redback"] = true, ["Hermit"] = true, ["Venom"] = true,
|
22 |
["Recluse"] = true, ["Redback"] = true, ["Hermit"] = true, ["Venom"] = true,
|
23 |
["Crab"] = true, ["Widow"] = true, ["Pyro"] = true, ["Moderator"] = true,
|
23 |
["Crab"] = true, ["Widow"] = true, ["Pyro"] = true, ["Moderator"] = true,
|
24 |
["Placeholder"] = true, ["Jack"] = true, ["Firewalker"] = true, ["Puppy"] = true,
|
24 |
["Placeholder"] = true, ["Jack"] = true, ["Firewalker"] = true, ["Puppy"] = true,
|
25 |
["Jugglenaut"] = true, ["Skuttle"] = true, ["Blitz"] = true, ["Ogre"] = true,
|
25 |
["Jugglenaut"] = true, ["Skuttle"] = true, ["Blitz"] = true, ["Ogre"] = true,
|
26 |
["Minotaur"] = true, ["Emissary"] = true, ["Kodachi"] = true, ["Cyclops"] = true,
|
26 |
["Minotaur"] = true, ["Emissary"] = true, ["Kodachi"] = true, ["Cyclops"] = true,
|
27 |
["Tremor"] = true, ["Duck"] = true, ["Buoy"] = true, ["Scallop"] = true,
|
27 |
["Tremor"] = true, ["Duck"] = true, ["Buoy"] = true, ["Scallop"] = true,
|
28 |
["Bulkhead"] = true, ["Lobster"] = true, ["Archer"] = true, ["Grizzly"] = true,
|
28 |
["Bulkhead"] = true, ["Lobster"] = true, ["Archer"] = true, ["Grizzly"] = true,
|
29 |
["Limpet"] = true, ["Hunter"] = true, ["Mistral"] = true, ["Corsair"] = true,
|
29 |
["Limpet"] = true, ["Hunter"] = true, ["Mistral"] = true, ["Corsair"] = true,
|
30 |
["Siren"] = true, ["Envoy"] = true, ["Cutter"] = true, ["Seawolf"] = true,
|
30 |
["Siren"] = true, ["Envoy"] = true, ["Cutter"] = true, ["Seawolf"] = true,
|
31 |
}
|
31 |
}
|
32 |
\n
|
32 |
\n
|
33 |
for name, ud in pairs(UnitDefs) do
|
33 |
for name, ud in pairs(UnitDefs) do
|
34 |
if validUnitNames[ud.name] then
|
34 |
if validUnitNames[ud.name] then
|
35 |
if ud.metalcost > highestmetalcost then
|
35 |
if ud.metalcost > highestmetalcost then
|
36 |
highestmetalcost = ud.metalcost
|
36 |
highestmetalcost = ud.metalcost
|
37 |
end
|
37 |
end
|
38 |
if ud.metalcost < lowestmetalcost then
|
38 |
if ud.metalcost < lowestmetalcost then
|
39 |
lowestmetalcost = ud.metalcost
|
39 |
lowestmetalcost = ud.metalcost
|
40 |
end
|
40 |
end
|
41 |
end
|
41 |
end
|
42 |
end
|
42 |
end
|
43 |
\n
|
43 |
\n
|
44 |
for name, ud in pairs(UnitDefs) do
|
44 |
for name, ud in pairs(UnitDefs) do
|
45 |
if validUnitNames[ud.name] then
|
45 |
if validUnitNames[ud.name] then
|
46 |
local distance_metalcost_midpoint = ud.metalcost - lowestmetalcost
|
46 |
local distance_metalcost_midpoint = ud.metalcost - lowestmetalcost
|
47 |
ud.metalcost = highestmetalcost - distance_metalcost_midpoint
|
47 |
ud.metalcost = highestmetalcost - distance_metalcost_midpoint
|
48 |
end
|
48 |
end
|
49 |
end
|
49 |
end
|
|
|
50 |
}}}
|
50 |
[/spoiler]
|
51 |
[/spoiler]
|