if you are using "type(image)" it return "userdata", would it be possible change it to "image" ?
and is it possible to load images from a url, without saving it to your pc?
local http = require"socket.http"
http.request{
url = "http://i.imgur.com/YGmjfbG.jpg",
sink = function(chunk, err)
if chunk then
f = love.filesystem.newFile("cat.png")
f:open('a')
f:write(chunk)
f:close()
end
return 1
end
}
error(type(love.graphics.newImage("cat.png")),2,love.filesystem.remove("cat.png"))
For the former, using [wiki]Object:type[/wiki] instead of lua's type function would be the solution.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
local text = "Hello World!"
local textType = text:type()
-- this will fail and "blue screen" --> Main.lua 2: attempt to call method 'type' (a nil value)
That's to be expected since löve doesn't modify the metatables for basic types (if they have/support one anyway), so it does not add type to them as a callable function.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.