I've never heard of Lua, but now that I am looking at it, it seems very friendly. Love how they call things what they are, for example `local` is just a local variable, or `repeat X until Y` for a loop. It's a joy to see, to be honest.
1-index kept throwing me off though
I open sourced my game along with a tutorial on how to make it using Lua
11–20 of 96 posts
Re: I open sourced my game along with a tutorial on how to make it using Lua
#12I've never heard of Lua, but now that I am looking at it, it seems very friendly. Love how they call things what they are, for example `local` is just a local variable, or `repeat X until Y` for a loop. It's a joy to see, to be honest.
1-index kept throwing me off though
Like a string will always be:
s:sub(1, #s)
And a sequence table will always be: for i = 1, #t do
t[i]
endRe: I open sourced my game along with a tutorial on how to make it using Lua
#13Re: I open sourced my game along with a tutorial on how to make it using Lua
#14Earlier quoted context omitted.
1-index kept throwing me off though
Once you get used to it, it does help prevent a whole bunch of off by one errors though, as you don't need math when grabbing a range. Like a string will always be: s:sub(1, #s) And a sequence table will always be: for i = 1, #t do t[i] end
function split_dot(s)
local idx = s:find(".", 1, true)
if not idx then return s end
return s:sub(1,idx-1), s:sub(idx+1)
end
It may come as a surprise that one should use a difference of 2 to skip over one character!In a language that used the half-open interval convention we would end up with:
s:sub(0, #s)
and for i = 0, #t do
t[i]
end
which seem just as good to me.Re: I open sourced my game along with a tutorial on how to make it using Lua
#15Re: I open sourced my game along with a tutorial on how to make it using Lua
#16I've never heard of Lua, but now that I am looking at it, it seems very friendly. Love how they call things what they are, for example `local` is just a local variable, or `repeat X until Y` for a loop. It's a joy to see, to be honest.
Check out (the now unfortunately named) CoronaSDK from (the also unfortunately named) Corona Labs. It's all Lua based and is now entirely MIT open sourced. One of the easiest to code cross platform development languages there is.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#17Re: I open sourced my game along with a tutorial on how to make it using Lua
#18I've never heard of Lua, but now that I am looking at it, it seems very friendly. Love how they call things what they are, for example `local` is just a local variable, or `repeat X until Y` for a loop. It's a joy to see, to be honest.
https://www.wowhead.com/guide=5338/comprehensive-beginners-g...
Re: I open sourced my game along with a tutorial on how to make it using Lua
#19https://github.com/a327ex/blog/issues/35 - BYTEPATH Postmortem (2018)
https://github.com/a327ex/blog/issues/44 - One Year Sales Data for BYTEPATH (2019)
Re: I open sourced my game along with a tutorial on how to make it using Lua
#20Earlier quoted context omitted.
Once you get used to it, it does help prevent a whole bunch of off by one errors though, as you don't need math when grabbing a range. Like a string will always be: s:sub(1, #s) And a sequence table will always be: for i = 1, #t do t[i] end
I disagree. Particularly when parsing strings, it's useful if the upper bound of one substring is the lower bound of a nonoverlapping substring immediately after. For example, here's a routine to split a string into the part before the first dot and the part after: function split_dot(s) local idx = s:find(".", 1, true) if not idx then return s end return s:sub(1,idx-1), s:sub(idx+1) end It may come as a surprise that…
s:sub(0, #s)
You would end up with: s:sub(0, #s - 1)
Which demonstrates the off-by-one error.