Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onLoad()
- planetLocations = {}
- planetLocations[1] = {}
- planetLocations[2] = nil
- planetLocations[3] = nil
- planetRelativeLocations = {}
- planetRelativeLocations[1] = {0,1,0}
- planetRelativeLocations[2] = {0,0,0}
- planetRelativeLocations[3] = {0,0,0}
- yOffset = 0
- recalibratePlanetLocations()
- button_parameters = {}
- button_parameters.position = {0,1,0}
- button_parameters.click_function = 'test1'
- button_parameters.label = "test1"
- button_parameters.function_owner = self
- button_parameters.width = 500
- button_parameters.height = 500
- button_parameters.color = {0,0,0}
- button_parameters.font_size= 250
- button_parameters.font_color= {1,1,1}
- self.createButton(button_parameters)
- end
- function test1()
- highlightPlanets()
- end
- function highlightPlanets()
- for i,j in pairs (planetLocations) do
- if planetLocations[i] ~= nil then
- highlightAtLocation(j, 3)
- end
- end
- end
- function highlightAtLocation(coord, r)
- recalibratePlanetLocations()
- --print("coords: "..coord[1]..", "..coord[2]..", "..coord[3].."; radius: "..r)
- local onPlanet = findInSphere(coord, r)
- for i, j in pairs (onPlanet) do
- if j.hit_object.getName() == "Infantry" then
- j.hit_object.highlightOn({0.5,1,0.8})
- end
- end
- end
- function recalibratePlanetLocations()
- for i,v in pairs (planetRelativeLocations) do
- if planetLocations[i] ~= nil then
- planetLocations[i][1] = planetRelativeLocations[i][1] + self.getPosition()[1]
- planetLocations[i][2] = planetRelativeLocations[i][2] + self.getPosition()[2] + yOffset
- planetLocations[i][3] = planetRelativeLocations[i][3] + self.getPosition()[3]
- end
- end
- end
- function findInSphere(x, r)
- local CastVectorOrigin =
- {
- x[1],
- x[2],
- x[3]
- }
- return Physics.cast({
- origin=CastVectorOrigin,
- type=2,
- size={r,r,r},
- max_distance = 4,
- direction = {0,1,0},
- debug = true
- })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement