/
scenario_10_empty.lua
90 lines (84 loc) · 4.41 KB
/
scenario_10_empty.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-- Name: Empty space
-- Description: Empty scenario, no enemies, no friendlies. Can be used by a GM player to setup a scenario in the GM screen. The F5 key can be used to copy the current layout to the clipboard for use in scenario scripts.
-- Type: Development
--- Scenario
-- @script scenario_10_empty
function init()
--SpaceStation():setPosition(1000, 1000):setTemplate('Small Station'):setFaction("Human Navy"):setRotation(random(0, 360))
--SpaceStation():setPosition(-1000, 1000):setTemplate('Medium Station'):setFaction("Human Navy"):setRotation(random(0, 360))
--SpaceStation():setPosition(1000, -1000):setTemplate('Large Station'):setFaction("Human Navy"):setRotation(random(0, 360))
--SpaceStation():setPosition(-1000, -1000):setTemplate('Huge Station'):setFaction("Human Navy"):setRotation(random(0, 360))
--player1 = PlayerSpaceship():setFaction("Human Navy"):setTemplate("Atlantis"):setRotation(200)
--player2 = PlayerSpaceship():setFaction("Human Navy"):setTemplate("Atlantis"):setRotation(0)
--Nebula():setPosition(-5000, 0)
--Artifact():setPosition(1000, 9000):setModel("small_frigate_1"):setDescription(_("scienceDescription-artifact", "An old space derelict."))
--Artifact():setPosition(9000, 2000):setModel("small_frigate_1"):setDescription(_("scienceDescription-artifact", "A wrecked ship."))
--Artifact():setPosition(3000, 4000):setModel("small_frigate_1"):setDescription(_("scienceDescription-artifact", "Tons of rotting plasteel."))
--addGMFunction(_("buttonGM", "move 1 to 2"), function() player1:transferPlayersToShip(player2) end)
--addGMFunction(_("buttonGM", "move 2 to 1"), function() player2:transferPlayersToShip(player1) end)
--CpuShip():setTemplate("Adder MK5"):setPosition(0, 0):setRotation(0):setFaction("Human Navy")
--CpuShip():setTemplate("Piranha F12"):setPosition(2000, 0):setRotation(-90):setFaction("Kraylor")
local planet1 = Planet():setPosition(5000, 5000):setPlanetRadius(3000):setDistanceFromMovementPlane(-2000):setPlanetSurfaceTexture("planets/planet-1.png"):setPlanetCloudTexture("planets/clouds-1.png"):setPlanetAtmosphereTexture("planets/atmosphere.png"):setPlanetAtmosphereColor(0.2, 0.2, 1.0)
local moon1 = Planet():setPosition(5000, 0):setPlanetRadius(1000):setDistanceFromMovementPlane(-2000):setPlanetSurfaceTexture("planets/moon-1.png"):setAxialRotationTime(20.0)
local sun1 = Planet():setPosition(5000, 15000):setPlanetRadius(1000):setDistanceFromMovementPlane(-2000):setPlanetAtmosphereTexture("planets/star-1.png"):setPlanetAtmosphereColor(1.0, 1.0, 1.0)
planet1:setOrbit(sun1, 40)
moon1:setOrbit(planet1, 20.0)
addGMFunction(
_("buttonGM", "Random asteroid field"),
function()
cleanup()
for n = 1, 1000 do
Asteroid():setPosition(random(-50000, 50000), random(-50000, 50000)):setSize(random(100, 500))
VisualAsteroid():setPosition(random(-50000, 50000), random(-50000, 50000)):setSize(random(100, 500))
end
end
)
addGMFunction(
_("buttonGM", "Random nebula field"),
function()
cleanup()
for n = 1, 50 do
Nebula():setPosition(random(-50000, 50000), random(-50000, 50000))
end
end
)
addGMFunction(
_("buttonGM", "Delete unselected"),
function()
local gm_selection = getGMSelection()
for _, obj in ipairs(getAllObjects()) do
local found = false
for _, obj2 in ipairs(gm_selection) do
if obj == obj2 then
found = true
end
end
if not found then
obj:destroy()
end
end
end
)
end
function cleanup()
-- Clean up the current play field. Find all objects and destroy everything that is not a player.
-- If it is a player, position him in the center of the scenario.
for _, obj in ipairs(getAllObjects()) do
if obj.typeName == "PlayerSpaceship" then
obj:setPosition(random(-100, 100), random(-100, 100))
else
obj:destroy()
end
end
end
function update(delta)
-- No victory condition
end
-- Set callback function
onNewPlayerShip(
function(ship)
-- Decide what you do with new ships:
print(ship, ship.typeName, ship:getTypeName(), ship:getCallSign())
-- ship:destroy()
end
)