What are you working on currently? (2017)

Today’s adventure involved writing a system that makes it easy to test features and capabilities of the engine. Here’s a selection of tests that show it off:

-- `feature.lua == true` if no subtests fail.
define("lua", {
	-- Failed subtests are logged for later scrutiny. Subtest names are used
	-- only for logging.
	{"base", {
		{"_G",       standard, type(_G) == "table"},
		{"_VERSION", standard, type(_VERSION) == "string"},
		{"assert",   standard, type(assert) == "function"},
	}},
	-- Tests can be wrapped in a function to avoid runtime errors
	-- (e.g. indexing `table` when it doesn't exist).
	{"table", function()return{
		type(table) == "table",
		{"insert",  standard, type(table.insert) == "function"},
		{"remove",  standard, type(table.remove) == "function"},
		{"foreach", optional, type(table.foreach) == "function"},
		{"maxn",    optional, type(table.maxn) == "function"},
		-- Optional tests are logged, but do not cause the parent test to fail.
	}end},
})

define("roblox", {
	-- Failure of a required test causes subsequent tests to be ignored; their
	-- assumed failure wont spam the log.
	{"lua", required, feature.lua},
	{"base", {
		{"game", standard, type(game) == "userdata"},
		{"wait", standard, type(wait) == "function"},
		{"Game", optional, type(Game) == "userdata"},
		{"Wait", optional, type(Wait) == "function"},
	}},
	{"math", function()return{
		{"clamp", standard, type(math.clamp) == "function"},
		{"noise", standard, type(math.noise) == "function"},
		{"sign",  standard, type(math.sign) == "function"},
	}end},
})

-- Define features that may actually be useful.
define("HttpEnabled", {feature.roblox, function()
	local ok, result = pcall(function()
		game:GetService("HttpService"):GetAsync("https://www.roblox.com/robots.txt")
	end)
	return not ok and result ~= "Http requests are not enabled" or ok
end})

define("LoadstringEnabled", {feature.roblox, function()
	return not not loadstring("")
end})

-- Elsewhere...
if feature.HttpEnabled then
	-- We can use HttpService!
end
if feature.LoadstringEnabled then
	-- We can use loadstring!
end

The fun part was writing it with as few dependencies as possible. The implementation requires only pcall for calling functions and type for checking values, though it’s possible to use only pcall (e.g. pcall(function(v) return v+1 end, value) == true means value is a number).

6 Likes

"1" + 1 is a number
pcall(function(v) return v+1 end, "1") is true

For the HttpEnabled one it’s actually enough to pass a non-empty string in the GetAsync, i.e. “a” will also work. You’ll get a trust check failed for that too and a “Http requests are not enabled” if http is not enabled. Just in case you prefer to have it shorter.

Also the “or ok” there at the end is superfluous, isn’t it?

Indeed. It would be written better as ok or result ~= "Http requests are not enabled"

I went with robots.txt because I wanted the request to be an endpoint that would almost certainly exist (regardless of trust status), to produce a relatively small response, and to not be some arbitrary website like example.com or google.com.

Challenge: detect types using only pcall.

I’ve been working on music

I really really want to get better at it. This is my latest little project
https://clyp.it/ba1mpwif

8 Likes

That’s awesome. Sounds like Ratchet & Clank/Crash Bandicoot had a baby.

1 Like

Something sounds too dissonant with the music to me. I’m sorry I don’t have anything more constructive to offer, but I don’t believe I have the vocabulary to describe what it is I find off putting. Perhaps… noisy? It’s too noisy? The rhythm dominates the music and thus overshadows what I would intuit to be the lead instrument.

1 Like

Yeah no definitely, I’m still a huge noob at making music as I only started learning production ~4 months ago. I do struggle a lot with mixing and I think I use too much reverb, really I’m trying to work on getting myself to cut back on layering sounds on top of sounds on top of sounds because often the music that I’m working on just ends up becoming a sausage of sound with a constant volume where nothing in particular actually stands out

@ScriptOn , :stuck_out_tongue: that brings me some nostalgia. I’ve also been told that some of my tracks sound like PS2 racing game music Stream Running through the city by citre | Listen online for free on SoundCloud

Sounds like your playing on 2 different keys, the high pitch sounds more minor than the main melody, you should try looking into keys that work together (totally forgot what they’re called since it’s been so long.)

Working on a gamepass that lets you see the population graph of my game, like in Age of Empires II.

9 Likes

That’s super cool but how do you get that many frames to not utterly destroy the framerate??

Yeah you’re probably right, I keep making the notes without thinking about harmonization
My producer friend always bugs me that I need to learn more music theory

1 Like

It’s not 1x1 pixels, it’s bars per width. I could make it more efficient if I wanted, but it hasn’t shown to be an issue to render. I can always lower the resolution if needed.

Plan on turning this into an animated short.

17 Likes

Yeah, music theory is a must, really helps develop your “musical ear”.

1 Like

Honestly ui elements rendering on the screen don’t cause too much lag. On my laptop which is just about to celebrate its tenth birthday I tested this out, I made the game spawn 10,000 2x2 frames at the same time… and tween them. It only started lagging a little when I bumped up to around 50k. And keep in mind this is frames that are all tweening at the same time so on computers that are even slightly more modern and without tweening the frames, he’ll have no problem at all.

Making them myself :smiley:, thanks!

What is it with us dutchies and trains? :grin:

1 Like

Lol good question :joy:

compensating for Fyra is my guess

2 Likes