Recently, I have been playing Widelands. Well, cheating on its single player mode.

https://farm6.staticflickr.com/5099/5468023929_3fc5d9fa6c_b.jpg

I never like playing games single-play mode if I dont cheat. The fun of playing is to cheat and beat the hell out of computer players.

Its actually not about cheating but more about coding if you need to find the address in save file. Though, there is usually cheatcode available, then you need to cheat with creativity.

Anyway, a week ago, I installed Widelands. After I looked into its save file. Meh, they are binary! I groaned. I read there is Lua embedded, so I decided to go using Lua.

I have tried to learn Lua about a year ago, but I didnt finish. Probably even before I learned its control flow. This time I did learn some from cheating on this game.

The release package doesnt have debug console, you need to download the repo. For that, I have to whine about how slow bzr is. I waited probably for an hour or even longer for bzr to clone the repo. Anyway, you compiled it with debug mode.

Once you enter the game and start a map, F6 is the start point to be a cheater. There is no command history , you cant use Up arrow key. So I found I can use dofile() and thats how this script comes.

You can get the script on Gist.

Save it to any filename you like to Widelands directory. Bring up the console and type dofile('filename.lua'). There are some functions you can call:

  • w999() fills up your warehouses.
  • sw() 100 solders at max skill levels in your warehouses.
  • sm() maximal solders at max skill levels in your military sites.
  • ntns() no tree, no stones.
  • aspca() anti-space. Kills all wild animals.
  • fh() a helper function which calls functions above at once except sw().
  • blacksheepwall() Do you StarCraft?
  • blind() reverses the function above.
  • cq(plr, x, y, radius) conquer an area.
  • pb(plr, name, x, y) places a building.
  • rmim(x, y) removes something from the location.

Here is a list of problematic functions:

  • suicidalbob() removes others bobs.
  • ghosttown() They all dead! They all dead!
  • controlfreak() You conquer whole map.

I was thinking some funny stuff like letenemiesdothehardwork() or burnbabyburn() or asteroid(). But I didnt start to write them.

The script isnt finished and its not good. I only learned Lua for a few hours, what can you expect? I posted this because I dont want to play and cheat anymore, its time to remove Wasteland. I meant Widelands, somehow I kept calling it by Wasteland for some time.

I dont think I will ever code in Lua again, it doesnt suit my taste. I just cant be used to that you cant compare two tables contents simply by a == b, you need to do it by yourself. It doesnt have continue for a reason. Thats what this language is, I am not complaining, just point out what I dont like.