Defold 1.2.175 BETA

Shure, code is the same as yours. But I am testing this on android

function init(self)
	msg.post(".", "acquire_input_focus")
	self.target = "/screen_1#collectionproxy"
	self.manifest = resource.get_current_manifest()
end

local function callback_store_resource(self, hexdigest, status)
	if status == true then
		print("Successfully stored resource: " .. hexdigest)
		pprint({ AFTER_STORE = collectionproxy.missing_resources(self.target) })
	else
		print("Failed to store resource: " .. hexdigest)
	end
end

local function load_resources(self)
	local resources = collectionproxy.missing_resources(self.target)
	pprint("Missing resources", resources)
	for _, resource_hash in ipairs(resources) do
		http.request("http://192.168.1.192:8000/" .. resource_hash, "GET", function(self, id, response)
			if response.status == 200 then
				resource.store_resource(self.manifest, response.response, resource_hash, callback_store_resource)
			else
				print("Failed to download resource: " .. resource_hash)
			end
		end)
	end
end

local function refresh_manifest()
	http.request("http://192.168.1.192:8000/liveupdate.game.dmanifest", "GET", function(self, id, response)
		if response.status == 200 or response.status == 304 then
			print("New manifest loaded -> start store")
			resource.store_manifest(response.response, function(_, status)
				if status == resource.LIVEUPDATE_OK then
					print("Successfully stored manifest! -> reboot engine")
					sys.save(sys.get_save_file("NewLU_test", "NewLU_test"), { manifest_ready = true })
					sys.reboot()
				else
					print("Failed to store manifest, status: ", status)
				end
			end)
		end
	end)
end

function on_input(self, action_id, action)
	if action_id == hash("touch") and action.pressed then
		if sys.load(sys.get_save_file("NewLU_test", "NewLU_test")).manifest_ready then
			load_resources(self)
		else
			refresh_manifest()
		end
	end
end
2 Likes

Sorry, but i’m tired this time. Forgot to change the engine version in the LU settings…

2 Likes

No worries, it happens to all of us!

On that note, it reminds me, I should make another :coffee:

3 Likes