When opening a normal place file (rbxl), the game.PlaceId property is normally set to 0.
I use this property for detecting if I am testing the game in studio or not, so I can tell the game not to make HTTPRequests or use InsertService.
Recently, after publishing to Roblox, the property is changed to the ID of the place I just uploaded. This makes it difficult to see if I am testing in Studio.
local Debug_Mode = false
if (game.PlaceId == 0) then
Debug_Mode = true
end
print(Debug_Mode)
[b]After opening the place file for the first time, Debug_Mode returns true and game.PlaceId is 0
After publishing the game, Debug_Mode returns false and game.PlaceId is set to the ID of the place I just uploaded to.
If I close and re-open the place file, game.PlaceId returns back to 0 and Debug_Mode returns true.
[/b]
local HTTP_ENABLED = true
function HttpGet(url)
if HTTP_ENABLED then
local httpenabled, data = pcall(function() return http:GetAsync(url) end)
if not httpenabled then
HTTP_ENABLED = false
else
return data
end
end
end
function HttpGet(url)
if not HTTP_DISABLED then
local httpenabled, data = pcall(function() return http:GetAsync(url) end)
HTTP_DISABLED = not httpenabled
return data
end
end
function HttpGet(url)
if not HTTP_DISABLED then
local httpenabled, data = pcall(function() return http:GetAsync(url) end)
HTTP_DISABLED = not httpenabled
return data
end
end
Little bit nicer.[/quote]
Yeah, I wrote that code in the forum and I didn’t particularly think much about it.