Embbeded code

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
khofez
Prole
Posts: 12
Joined: Thu Dec 17, 2015 7:05 pm

Embbeded code

Post by khofez »

I would like to know how the guys that are developing love2d converted a lua file into an unsigned char array with hexadecimal letters separated by commas, for example boot.lua and nogame.lua.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Embbeded code

Post by zorg »

Don't know, but something like this should work:

Code: Select all

local data= {}
for line in love.filesystem.lines("code.lua") do
  for c in line:gmatch"." do
    data[#data+1] = ('%02X, '):format(c:byte()) 
  end
end
data = table.concat(data)
Me and my stuff :3True 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Embbeded code

Post by bartbes »

Using the file next to it: auto.lua.
khofez
Prole
Posts: 12
Joined: Thu Dec 17, 2015 7:05 pm

Re: Embbeded code

Post by khofez »

Thanks guys !
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 0 guests