Purpose

How to pass an instance of a structure/class to the script and have it call functions on it

Being naive I thought finding something like this would be easy. We all know how stories starting with "Being naive..." end (in road-side ditches surrounded by police tape).I used the latest Lua release (5.2) and stumbled across errors where functions were deprecated (lua_open no longer exists), examples where there was so much going on I simply couldn't understand the basics, examples where a script.lua file was simply executed, examples where in order to pass a C object over I had to create something called a MetaTable and and...

So here it is, a simple example that pretends it's a game. The idea would be that you have an enemy object and it's intelligence would be stored in a Lua script that is loaded at the start of the game, and the "onUpdate" function in that script is called every frame wherein it can change the position, state, colour, happiness, whatever of the object.

Note

This contains no error checking to keep things simple. The Lua documentation on how to do error checking is great, and you should check the result of every call you make, as well as checking to see if variables are actually the type you expect them to be before using them.Also, I started using Lua for the first time today, so this is simply an example that works for me, your mileage and joy in ignorance may vary.

Recently I started looking at ways to get Drumpster to output MIDI on non-Windows platforms and came across FluidSynth. It allows for MIDI playback and conversion to WAV files if you so choose. In order to do so, you need to provide a SoundFont (which provides instrument samples that are used to convert the MIDI data to wave data).

In my search for some free SoundFonts, I came across the Rhodes Piano one listed here (decompressor here), and I find it absolutely beautiful to listen to. It has a melancholic joy to it (making me think of Everclear), sometimes sounding menacing like the music in Tron.

So armed with the Rhodes SoundFont and a Windows binary from here, I converted a few MIDI files and put them up on SoundCloud.

To convert some yourself, an example commandline for this would be:

fluidsynth.exe -F output.wav input.mid jRhodes3.sf2

P.S. It also turns out that FluidSynth has a delightfully easy to use Python wrapper here.

This new version of Drumpster has been "ready" for ages now, I didn't want to release it because it simply isn't good enough.(the "MIDI Playback" button doesn't do anything unless you enable it in the configuration file first, there aren't proper icons for most binaries, I haven't tested it properly on all the platforms (32-bit or 64-bit OSX build... how should I know!?), the lyrics don't always load correctly...)However, when compared to v0.1, this has several major fixes and enhancements that make it worthwhile.

I also have a sneaking suspicion that I am going to have to rewrite the whole MIDI loading to notes on a timeline process. I currently load notes and convert them to their absolute time in milliseconds, mostly because I'm a dunce and I have no idea what I'm doing.What I've noticed is that this conversion process isn't ideal as a song with a slow tempo will throw the notes towards you at the same pace as a fast tempo song... meaning that the notes will either be scrunched up together or very far apart, making it difficult to read sometimes.So now I will have to store the notes and their tempo and change the rate of note flow accordingly.

Major fixes

MIDI loader is more stable and maps things more correctly now.

The splash-screen now works, a side-affect of the OpenGL code being slightly less beaten by the crazy-dog stick.

The OBJ loader is a bazillion times faster now, and is less against actually loading OBJ files.

Enhancements

Android build - I've tested it on a single device, all I own, if you have any tales of woe/joy, I'd love to hear about them at my Hotmail address, noshbar@, or Tweet to @noshbar

BlackBerry PlayBook build

The WebOS build has a funky feature where you can drag the timeline/fretboard back and forwards through time with your finger.

Lyrics are now loaded from the MIDI file and displayed during gameplay.

You can enable buggy MIDI audio playback by adding the following line to the drumpster.cfg file:

Download the source code and either add the files to a Visual Studio Win32 solution that links to SDL and Box2D, or on Linux do:

g++ main.cpp -lSDL -lBox2D

Progress

While this is by no means THE bridge builder tutorial (I intend on writing LOTS and making many pretty pictures), this shows the direction I'm going.

I'm not sure if I should start things really simple and build up, or if I should assume prior knowledge of renderers and physics engines (not that I know much about either of those anyway).I guessed that something like this would be a good start, then the next version would add images, show how to build for every platform under the sun, that kind of thing.

If anyone is reading this and by the same miracle is actually waiting to see what I come up with, I'd love to hear what you'd like to see.