Search found 650 matches

by airstruck
Thu Jul 16, 2015 12:11 pm
Forum: Support and Development
Topic: Is this a good timer that I made?
Replies: 4
Views: 2105

Re: Is this a good timer that I made?

It's a good start. I think there's some room for improvement. Avoid global variables Use the local keyword to create local variables and functions, and return a table with the things you want to export. This way everything stays encapsulated; your timer module doesn't interfere with other code and o...
by airstruck
Thu Jul 16, 2015 6:04 am
Forum: Support and Development
Topic: What are metatables? what is __index, __call ?
Replies: 2
Views: 1440

Re: What are metatables? what is __index, __call ?

Read (or at least skim) PIL chapter 13 , especially 13.4.1 . I think __call might have been added after PIL was written. It allows a table to be called like a function, using the normal function call syntax. When you call the table , the __call metamethod is invoked. It receives the table as the fir...
by airstruck
Thu Jul 16, 2015 5:53 am
Forum: General
Topic: Decimal to Binary function I made
Replies: 20
Views: 8589

Re: Decimal to Binary function I made

First we format the number into an hexadecimal string Could use octal and cut that table in half ;) I assign the value to the local variable result so that all the other return values provided by gsub are discarded You can wrap the expression in parens to get the same effect: return (string.format(...
by airstruck
Wed Jul 15, 2015 4:30 am
Forum: General
Topic: Decimal to Binary function I made
Replies: 20
Views: 8589

Re: Decimal to Binary function I made

Could shorten a bit. Could just as easily shorten it with table.concat , probably better than doing all that string concatenation. Not sure only converting to binary is very useful, might as well add the extra line or two to convert to arbitrary base. local function toBase (base, number) local resu...
by airstruck
Tue Jul 14, 2015 8:56 pm
Forum: Support and Development
Topic: [Solved]Strange Console Output
Replies: 9
Views: 4528

Re: [Solved]Strange Console Output

Linkpy wrote:\r
Ahh, that's clever, I like it. Had to add io.flush() after it to get it to show up. Does this work on Mac, or do they still use \r as a line break?
by airstruck
Tue Jul 14, 2015 5:08 am
Forum: LÖVE-Android
Topic: [SOLVED] Error when trying to compile LÖVE-Android
Replies: 7
Views: 9708

Re: Error when trying to compile LÖVE-Android

I think you need C++11, try updating gcc/g++
by airstruck
Mon Jul 13, 2015 6:01 am
Forum: Libraries and Tools
Topic: Small event handling module
Replies: 2
Views: 2570

Re: Small event handling module

Reminds me of javascript EventListeners or jquery binds. I like it. Thanks, it's partly inspired by EventListeners and partly by "DOM 0" events (in that you can return false from within a handler to stop other handlers from processing the event, forgot to mention that). Is this common in ...
by airstruck
Mon Jul 13, 2015 5:22 am
Forum: Libraries and Tools
Topic: Small event handling module
Replies: 2
Views: 2570

Small event handling module

This module provides a simple way to register multiple handlers for events. The module has no knowledge of Love's API, so the first step (in main.lua) is this: local Event = require 'event' Event.injectDispatchers(love.handlers) Event.injectDispatchers(love, { 'load', 'update', 'draw' }) This "...
by airstruck
Sat Jul 11, 2015 8:41 pm
Forum: Support and Development
Topic: Writing into TXT
Replies: 19
Views: 10450

Re: Writing into TXT

It sounds like you need two things, a Lua binary serialization library and something like a Lua ascii85 encoder or Lua base64 encoder.

Always helps to know what you're looking for.
by airstruck
Wed Jul 08, 2015 3:29 pm
Forum: Support and Development
Topic: [Solved]Strange Console Output
Replies: 9
Views: 4528

Re: [Solved]Strange Console Output

Don't be sorry, I was just confused because OP marked this as [solved] right after you posted that. It would be good if people would take the time to leave a note about how their problem was solved to avoid confusing people who find the thread later. Could be that OP settled for printing everything ...