mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-04-19 08:26:54 +00:00
32 lines
1.9 KiB
Plaintext
32 lines
1.9 KiB
Plaintext
local COLLISION_RESPONSE = hash("collision_response")
|
|
|
|
function refresh_pods()
|
|
http.request("https://ocmaster39:8443/api/v1/namespaces/foobar/pods", "GET", http_pod_result,headers)
|
|
end
|
|
|
|
function init(self)
|
|
msg.post(".", "acquire_input_focus")
|
|
token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJmb29iYXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlY3JldC5uYW1lIjoiYm90LXRva2VuLTZiNndkIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImJvdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjRmZTZkOWUwLWRlNjEtMTFlOC1hOTIzLTIyM2Q5NTVhNzBlOSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpmb29iYXI6Ym90In0.GwuazgmPxWIGgFNuVQxpNz5kXweuPjUHMnsemX1YJAINYgzvZ2FMaTCqJJ1pN3Vdk05KA9YD69lJLYv3kBDSeTdWOCuIYSGyq0EPhUu5eGdFvDxg1Hqj58XWTfNS79Yb3jPTTETGLqDPLJIMqKbmvIERxVZlVT8cGWo6xVhDrUaA0YrGD6SFdvh35pqGV-hmyyzhqU27p51zUG4cYv9KVk1TVVJst2qDIoB2vCnab04qaaPuWB3GmVQLXEG09qqGWvYuil88gb76iMNv7vfX3FMKuENxD175et5hhIbEjWg2jdxqGzZ6wj8Qi19WJr-1fREk_loefi-1ipC-zc5uLw"
|
|
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 colision 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}
|
|
go.delete(value["id"])
|
|
end
|
|
end
|
|
end
|
|
print "[on_message] end of on_message function"
|
|
end |