Permalink
Browse files

Restructuring of Interfaces.lua's selection table. Moved 'control' an…

…d 'target' variables underneath the ship's ai section, which is where it should be.

Signed-off-by: Adam Hintz <adam.o.dev@gmail.com>
  • Loading branch information...
1 parent 6d86c88 commit 41f5b9c35c3765a86a05632ccb8fbdae74aaa895 @adam000 committed Aug 27, 2011
View
2 Resources/Scripts/Modes/Ares/KeyControls.lua
@@ -75,7 +75,7 @@ function update()
end
-- [TODO] [FIX] [ADAM] mouse button handling
- -- What we need is a table in KeyboardControl.lua that shows
+ -- What we need is a table in KeyboardControl.lua that shows (...? unfinished)
if mup then
mup = false
mousePos = input.mouse_position()
View
12 Resources/Scripts/Modes/Demo4.lua
@@ -29,11 +29,13 @@ function init()
scen = LoadScenario(demoLevel)
+--[[
selection.control = scen.playership
selection.controlId = scen.playerShipId
selection.target = nil
selection.targetId = nil
-
+--]]
+
window.mouse_toggle()
end
@@ -405,11 +407,11 @@ function mouse_up()
print(cameraRatio.current)
local mousePos = GetMouseCoords()
if keyboard[2][5].active then -- TARGET
- selection.targetId, selection.target = NextTargetUnderCursor(selection.targetId, true)
+ scen.playerShip.ai.objectives.targetId, scen.playerShip.ai.objectives.target = NextTargetUnderCursor(scen.playerShip.ai.objectives.targetId, true)
else -- CONTROL
- selection.controlId, selection.control = NextTargetUnderCursor(selection.controlId, false)
- if selection.control.base.attributes.canAcceptBuild then
- selection.lastPlanet = selection.control
+ scen.playerShip.ai.objectives.controlId, scen.playerShip.ai.objectives.control = NextTargetUnderCursor(scen.playerShip.ai.objectives.controlId, false)
+ if scen.playerShip.ai.objectives.control.base.attributes.canAcceptBuild then
+ selection.lastPlanet = scen.playerShip.ai.objectives.control
CalculateBuildables(selection.lastPlanet, scen)
end
end
View
2 Resources/Scripts/Modules/GlobalVars.lua
@@ -89,5 +89,5 @@ menuLevel = menuOptions
-- client-server variables
isMultiplayer = false
--- metatable variable?
+-- metatable variable for garbage collection
weak = {__mode = "v"}
View
18 Resources/Scripts/Modules/Interfaces.lua
@@ -3,13 +3,17 @@ import('BoxDrawing')
import('Camera')
import('TextManip')
+-- The below should be removed ASAP in favor of using scen.playerShip.ai.objectives,
+-- and lastPlanet should be put under the Admiral AI, as the player should have
+-- one "last planet" selected at a time? [TODO]
+
selection = {
- control = {},
- target = {},
+-- control = {},
+-- target = {},
lastPlanet = nil
}
-setmetatable(selection, weak)
+-- setmetatable(selection, weak) -- is this line necessary?
menuShift = 54
topOfMenu = -87
@@ -481,12 +485,12 @@ function DrawPanels()
end
end
- if selection.control ~= nil then
- DrawTargetBox(selection.control, true)
+ if scen.playerShip.ai.objectives ~= nil and scen.playerShip.ai.objectives.control ~= nil then
+ DrawTargetBox(scen.playerShip.ai.objectives.control, true)
end
- if selection.target ~= nil then
- DrawTargetBox(selection.target, false)
+ if scen.playerShip.ai.objectives ~= nil and scen.playerShip.ai.objectives.target ~= nil then
+ DrawTargetBox(scen.playerShip.ai.objectives.target, false)
end
-- printTable(panels)
View
4 Resources/Scripts/Modules/KeyboardControl.lua
@@ -162,6 +162,8 @@ function DoTarget()
end
function DoMoveOrder()
+ local selection = scen.playerShip.ai.objectives
+
if selection.control ~= nil
and selection.control ~= selection.target
and selection.control ~= scen.playerShip
@@ -237,6 +239,8 @@ end
-------------]]--
function DoTransferControl()
+ local selection = scen.playerShip.ai.objectives
+
if selection.control ~= nil
and (
not(RELEASE_BUILD)
View
4 Resources/Scripts/Modules/ShipBuilding.lua
@@ -60,8 +60,8 @@ function UpdatePlanet(planet, dt)
newObj.physics.position = planet.physics.position
newObj.ai.owner = planet.ai.owner
if newObj.ai.owner == 0
- and selection.target ~= nil then
- newObj.ai.objectives.dest = selection.target
+ and scen.playerShip.ai.objectives.target ~= nil then
+ newObj.ai.objectives.dest = scen.playerShip.ai.objectives.target
else
newObj.ai.objectives.dest = planet
end

0 comments on commit 41f5b9c

Please sign in to comment.