1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

Merge pull request #15 from Quadrum1/junkyard-fix

Junkyard fix / scrap.lua
This commit is contained in:
Gerkiz 2021-03-27 14:53:53 +01:00 committed by GitHub
commit 27428b27c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 543 additions and 496 deletions

File diff suppressed because it is too large Load Diff

52
tools/scrap.lua Normal file
View File

@ -0,0 +1,52 @@
local Public = {}
local math_random = math.random
local scrap_list = {
"crash-site-spaceship-wreck-small-1",
"crash-site-spaceship-wreck-small-2",
"crash-site-spaceship-wreck-small-3",
"crash-site-spaceship-wreck-small-4",
"crash-site-spaceship-wreck-small-5",
"crash-site-spaceship-wreck-small-6"
}
function Public.create_scrap(surface, position)
local scraps = {
"crash-site-spaceship-wreck-small-1",
"crash-site-spaceship-wreck-small-1",
"crash-site-spaceship-wreck-small-2",
"crash-site-spaceship-wreck-small-2",
"crash-site-spaceship-wreck-small-3",
"crash-site-spaceship-wreck-small-3",
"crash-site-spaceship-wreck-small-4",
"crash-site-spaceship-wreck-small-4",
"crash-site-spaceship-wreck-small-5",
"crash-site-spaceship-wreck-small-5",
"crash-site-spaceship-wreck-small-6"
}
surface.create_entity({name = scraps[math_random(1, #scraps)], position = position, force = "neutral"})
end
function Public.random_scrap_name()
return scrap_list[math_random(1, #scrap_list)]
end
function Public.get_scrap_name(index)
if index > #scrap_list then return scrap_list[1] end
if index < 1 then return scrap_list[1] end
return scrap_list[index]
end
function Public.get_scraps()
return scrap_list
end
function Public.get_scrap_true_array()
local true_array = {}
for _, e in pairs (scrap_list) do
true_array[e] = true
end
return true_array
end
return Public