rushed by this at first, thinking the top was a picture irl.
Either I need my eyes checked, or you’re doing gods work.
inb4 Apoc Rising increases map size for this
That looks beautiful! Keep posting progress pics
I’m sorry. This thread is for roblox development.
Nice. The only type it fails on is a userdata with a specifically tailored metatable, which is probably impossible to get around anyway.
function isNumber(val)
return pcall(function() return val+1 end) and not
pcall(function() return #val end)
end
local ud = newproxy(true)
local mt = getmetatable(ud)
mt.__add = function() return 1 end
mt.__sub = function() return 1 end
mt.__mul = function() return 1 end
mt.__div = function() return 1 end
mt.__mod = function() return 1 end
mt.__pow = function() return 1 end
mt.__unm = function() return 1 end
mt.__concat = function() return "" end
-- mt.__len = function() return 1 end
mt.__eq = function() return true end
mt.__lt = function() return true end
mt.__le = function() return true end
mt.__index = function() return true end
mt.__newindex = function() end
mt.__call = function() return true end
print("nil:", isNumber(nil))
print("boolean:", isNumber(true))
print("number:", isNumber(0))
print("string:", isNumber(""))
print("string num:", isNumber("0"))
print("function:", isNumber(function()end))
print("thread:", isNumber(coroutine.create(function()end)))
print("userdata:", isNumber(newproxy()))
print("userdata metatable:", isNumber(ud))
print("table:", isNumber({}))
print("table metatable:", isNumber(setmetatable({},mt)))
I talking about the methods, not strings themselves. The methods are applied when the string library is loaded. Here’s the bit of Lua source that does it (with annotations):
static void createmetatable (lua_State *L) { // local stringlib = string
lua_createtable(L, 0, 1); // local mt = {}
lua_pushliteral(L, ""); // local s = ""
lua_pushvalue(L, -2);
lua_setmetatable(L, -2); // setmetatable("", mt) -- Allowed in C API
lua_pop(L, 1);
lua_pushvalue(L, -2);
lua_setfield(L, -2, "__index"); // mt.__index = stringlib
lua_pop(L, 1);
}
We’re assuming that the environment only contains pcall
. If the string library were never loaded, then the methods wouldn’t be available.
Eh, this works better, using weird number magic:
function isNumber(val)
local suc,err = pcall(function() return val/(0/0)~=val/(0/0) end)
return suc and err and
pcall(function() return val+1 end) and not
pcall(function() return #val end)
end
Returns false for everything except the actual number with your test code. Could still be tricked by having two userdatas with a __div that counts how many divisions happened and do stuff based on that, but that’s just purely engineered to fail the test:
local i = 0
mt1.__div = function() i=i+1 return i%2==0 and ud1 or ud2 end
mt2.__div = function() i=i+1 return i%2==0 and ud1 or ud2 end
print(ud1/(0/0),ud1/(0/0)) --> ud2 ud1
(if it just returned itself, ud==ud
would return true, as it bypasses __eq and always returns true)
@zeuxcg isn’t doing the (apparently) impossible fun?
Wait isn’t this Source engine?
I swear that axis in the bottom left corner is photoshopped in…
lies
aww, what a shame I don’t see me there…
Fabulous art style! I’m sad I can’t come to RDC to see this stuff.
Wish you were coming to RDC UK .
Working on rebuilding the “Small Airliner” for RO-Port Tycoon. I’m trying to keep the blocky look-and-feel from the original, so I’m only using wedges and blocks. Got the nose part done so far.
The blue plane in the mid-ground is the original Small Airliner in the game which is getting replaced.
Edit: New vs. Old Airliner:
Yeah, it still looks kinda stupid, but it’s better than the old one!
damn that’s nice. really does have an ‘old school roblox’ feel. nice throwback.
game dev life?
0_o
that’s gonna be a really empty game
I finally was able to get my implementation of quickhull working in 3D. Simply feed in points and it will generate the faces/vertices of the hull. It’s pretty quick too!
Sorry in advance for the image dump.
My fiancé is a beginner and aspiring developer, hoping on eventually getting into the dev forum. She’s now working on maps with me for a stylized voxel shooter I’m working on. She made this little house after about an hour of learning the basic studio tools, and is working on an office. (We’re both sorta good at blender and other 3D modeling software but never have touched traditional roblox modeling).
This is a little off topic but I love seeing people who I developed (( around )) that are still active and working on projects years and years later