mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-04-06 18:36:52 +00:00
31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
local COLLISION_RESPONSE = hash("collision_response")
|
|
|
|
function refresh_pods()
|
|
http.request(endpoint .. "/api/v1/namespaces/" .. namespace .. "/pods", "GET", http_pod_result,headers)
|
|
end
|
|
|
|
function init(self)
|
|
msg.post(".", "acquire_input_focus")
|
|
headers = {
|
|
["Authorization"] = "Bearer " .. token ,
|
|
["Accept"] = "application/json",
|
|
["Content-Type"] = "application/json"
|
|
}
|
|
end
|
|
|
|
function on_message(self, message_id, message, sender)
|
|
print "[on_message] bullet object received a message"
|
|
if message_id == COLLISION_RESPONSE then
|
|
print "[on_message] collision detected"
|
|
for i,value in ipairs(current_pods) do
|
|
print("[on_message] pod of collision is " .. value["color"] .. " " .. "id is " .. message["other_id"] )
|
|
if value["color"] == "white" and value["id"] == message["other_id"] then
|
|
old_pos = go.get_position(value["id"])
|
|
print ("on_message] position of pod to be deleted is " .. old_pos)
|
|
current_pods[i] = { id = value["id"] , color = "red", collision = true, old_position = old_pos, pod_name = value["pod_name"] }
|
|
go.delete(value["id"])
|
|
end
|
|
end
|
|
end
|
|
print "[on_message] end of on_message function"
|
|
end |