Module API FAQ |
Shamousey « Consul » 1375211520000
| 1 | ||
MODULE API What is the Module API? The Module API is a minigame creation system built into Transformice that allows users to create minigames and utilities without the use of bots or external tools. It was originally announced here Topic-248549 and later released to the public here Topic-451620 What is a module? A module is the name given to a script running in a room. What are the different types of modules? There are three primary types of modules to take note of; approved official modules, approved unofficial modules, and unapproved modules. • Unapproved modules is the name given to scripts ran that aren't approved by an administrator. • Official modules show up on the /module list ingame, allow players to earn 1 cheese every 2 minutes, can be loaded through /module modulename in the tribe house, and work in any room starting with #modulename. • Unofficial modules are approved by administrators, can be loaded in the tribe house with /module modulename, and work in any room starting with #modulename. What's different about module rooms? There are several differences between module rooms when compared to regular rooms. • Stats are disabled. • /mort command is disabled. • There is no "Your last message is the same.". Who can use the Module API? Anyone can use it in their tribe house, providing they have 1000 cheese, permission to use the /np command, and they've never been banned for hacking. Additionally, people on the Lua Team can use it in any room where the name begins with a # character. What are all of the current official modules? You can type the command /module ingame to see a list of official modules. The number after the name is the amount of players currently in all rooms running that module combined. There is also an in-depth list of the current minigames kindly compiled by Icewolfbob here. Topic-52618 What are all of the current approved modules? You can ensure an up-to-date list of official modules using the above command, although they're also listed below. a dit : While there isn't an ingame list of unofficial modules, some are listed here. a dit : What's the difference between this and bots? While bots rely on a third party server to connect to the game and are not always guaranteed to be online, the Module API is built into the game and all official modules will be available, even directly after a server restart. Bots (even modbots) have less control over the room and can only perform tasks that regular users or moderators can do, that were never designed for minigames. Is there any documentation? There is documentation available, you can find the official ones here Topic-451587 or an unofficial version on kikoo.formice.com. Where can I suggest a feature/report a bug? There are dedicated threads for both Module API suggestions Topic-383236 and for bugs Topic-383230 that can be used for this. Who is on the Lua Team? The list of Lua Team members is private, although you can contact any of the following members on the team should you need something. The Lua Team isn't here to run your scripts in public, so please refrain from asking for that. • Jordynl • Shamousey • Thewav • Makinit • Safwanrockz How can I join the Lua Team? If you wish to join the Lua Team you must be referred by an existing member of the team. You must speak fluent English in order to communicate with the rest of the team, be a trusted member of the community and already have knowledge in using Lua. It's also a good idea if you already have a module you've created to show off your skills. Where can I get support when developing? There are three primary places you can go to when you need help developing your module; the forums, ingame channels, and IRC. The forums are full of people talking and giving support. If you have an error, check the Errors thread Topic-458983 or if you need a certain code snippet you can request it Topic-462959 although any general questions should be asked in this FAQ. While ingame you can type "/chat lua" to get to the private Lua discussion channel. Here people will be available to discuss and help you as you need. Likewise, joining the channel #tmlua on Rizon will connect you to a channel full of people from the Lua Team and other users. How can I get my module approved? Only members of the Lua Team can manage an approved module. If you would like your module to be approved, you can either request to join the Lua Team or ask a member of the team to run it for you. Why are certain functions disabled in the tribe house? While they're listed in the documentation, there are some functions that aren't available when using Lua in the tribe house. • tfm.exec.chatMessage() is disabled to prevent impersonation, spamming people's chat, or otherwise ruining it. • system.newTimer and system.removeTimer are disabled as timers can be heavy on server resources. • system.saveFile and system.loadFile are disabled as they can take up a lot of storage space. • tfm.exec.addImage() and tfm.exec.removeImage() are disabled due to potential abuse with inappropriate images. • tfm.exec.setRoomMaxPlayers() doesn't give an error, but doesn't work in the tribe house to stop people from joining. What is Lua? Lua (coming from the word "moon" in Portuguese) is a light programming language designed as a scripting language that has extensible semantics. Why Lua, and not some other language? Lua is a lightweight language with easy-to-learn syntax and is designed to be used for APIs and buit into other programs. It's well known and has a lot of documentation online. Where can I learn Lua? There are several places throughout the internet where Lua is well documented, and there are a lot of tutorials on learning to use it from being a total beginner. • Official Lua Website • Lua Reference Manual • Lua Users Wiki • Lua Unofficial FAQ • Learning Lua Guide • Quick overview of Lua • Learn Lua in 15 Minutes • Lua for Programmers • Learn Lua The Hard Way What programs can I use to write Lua code? The built in text box in the /lua window isn't particularly good for coding anything longer than a few lines. Tabs don't look right, it's not wide enough to see a lot of code and it doesn't have syntax highlighting, just to mention a few things. While any text editor will do, some external third party text editors or integrated development environments can do a good job of this. • Eclipse with Lua Development Tools or Lua Eclipse (IDE) • Lua Edit (IDE) • NotePad++ • Sublime Text • ZeroBrane Studio (IDE) Collaborative Text Editors If you wish to collaborate and code alongside someone else in realtime, there are several tools available to do just that. • Stypi - Real tabs (not just 4 spaces), syntax highlighting, custom layouts and features, saving documents, making them private, real time chat. • CodeShare - Has Lua syntax highlighting. • Google Docs • EtherPad, QikPad, Makinit's Pad - Collaborative text-editing sites running on the open source EtherPad software. • CollabEdit • Sync.in • PiratePad Lua Minifiers As there is a 64k character limit imposed when running code with the Module API, any long script may have to be minified. Minification makes the code smaller through practises such as removing linebreaks, whitespace, renaming functions and local variables to shorter alternatives, and the such to help reduce the overall size. • Squish • Mothereffin Lua Minifier (web based) Miscellaneous Resources • Lua for Windows (Windows) - Lua interpreter. • Lua Shell (Chrome) - Lua interpreter. • CodePad (Web) - Lua interpreter. • Keycodes - A list of keycodes and their corresponding characters to use in Lua. • ComputerCraft - A modification for MineCraft that adds computers to the game where you can program things in Lua. Modules are event driven, everything coded is ran at an event. The Module API has a lot of events passed from the main game that you can use, such as typing a !command, when a player joins a room, when a player presses a certain key, when they gather cheese, and many more. Anything that's not inside a function will be excecuted as soon as the script is ran. There are some notable differences when running a Lua script ingame compared to a standard Lua interpreter. • print() only displays to the player who runs the script. • A limited amount of HTML can be used within chat messages and print. • Only scripts that are 64k characters or less can be excecuted. • setmetatable and its corresponding functions don't exist. • io.write, io.read, and the rest of the io package don't exist. There are some general things to note when using the Module API that you should remember when coding. • Function names all use camelCase, meaning that the first word starts with a lowercase character and all subsequent ones start with an uppercase character. A good example of this is tfm.exec.eventDisableAllShamanSkills() • tfm.get.room.playerList doesn't update quickly, so co-ordinates, isMovingLeft, isMovingRight, isFacingRight, etc. can all be incorrect at times. • < and > characters can't be displayed in the chat, but < and > can. • tfm.exec.newGame() can't be excecuted quicker than 3 seconds since the last time it was ran. • tfm.exec.newGame() can take just the numbers from an @code, it doesn't have to be a string. • Loading specific perms with tfm.exec.newGame("#4") doesn't work in the tribe house. • There is a 1000 character limit for each chat message. • <COLOR> tags can be used in places that accept text (text areas, chat messages, UI, etc.), find a list of them here Topic-465671 The official documentation Topic-451587 displays all of the available functions and events in a way such as "eventPlayerDied(String playerName)". The first word of each argument in this documentation is the data type that this argument will return when the event is ran. You would make use of an event by first defining it as a function. a dit : You can then go on to add code within the function that makes use of the available arguments. a dit : Dernière modification le 1408211760000 |
Sharpiepoops « Citoyen » 1375211520000
| 0 | ||
Ohh good idea shamoosey |
Makinit « Citoyen » 1375211640000
| 1 | ||
Example code of the lagball minigame: http://pastebin.com/NuzTccgM |
0 | ||
Great documentation. :) |
Benbirkralm « Citoyen » 1375212000000
| 0 | ||
Perfect Documentation ^^ |
Xxninjazxx « Citoyen » 1375212360000
| 0 | ||
I've been waiting for a thread like this. I'm gonna try learning lua sometime soon. |
Impuredeath « Citoyen » 1375212900000
| 0 | ||
Good documentation, and I like that you referred to computercraft aswell ^^ |
Sloocky « Citoyen » 1375212900000
| 0 | ||
Good topic. \o Impuredeath a dit : sexy impure o: |
Shamousey « Consul » 1375214040000
| 0 | ||
Impuredeath a dit : ComputerCraft is amazing *-* We should get a small group of people together to play with it and see what our combined Lua skills can do! |
0 | ||
I've always learned by example, maybe others do the same. All of my scripts are open-source, but they might be too complex. Here's one that isn't, feel free to pick it apart: checkpoint.lua, a checkpoint (and more) system made for bootcamp testing. (no I don't comment, test your mettle) |
Evilsantah « Citoyen » 1375214700000
| 0 | ||
Good job Liam and yes I would like to try out ComputerCraft with you Liam!!1!! I didn't know about it. I like your reference to Sublime Text as editor, I use it and it's great to script/code in any language! |
Shamousey « Consul » 1375215360000
| 0 | ||
Fxie a dit : It's much appreciated sharing your code, I hope it helps out lots of people trying to learn! *-* Evilsantah a dit : ComputerCraft has lots of cool things for messing with redstone, it's got a lot more if you want to mess around with other mods too, if you want to try it out ;) I've used Sublime before but have ended up using Notepad++ as my primary editor as it has several plugins I've found that aren't available for Sublime yet, but I'm waiting for them to be out so I can try make the switch! |
Beachking « Citoyen » 1375221600000
| 0 | ||
Nice. Good Job Liam! |
0 | ||
Shamousey a dit : I'd like to add that creative and enthusiastic minds are highly welcome. Also, many in the current team didn't know lua when they joined (me included). As a consequence your skill in lua doesn't have to be very good if you already know one or multiple other programming languages. Please be adviced that claiming knowledge of programming languages you actually don't know is not a good idea. |
Vanilla « Citoyen » 1375221720000
| 0 | ||
Finally, there is a thread about this. |
Juliiien « Citoyen » 1375222140000
| 0 | ||
Thanks so much Sham' ! Edit: French translation done o/ |
Ratacp « Consul » 1375224420000
| 0 | ||
Would you mind if I translate this thread for the ES community? |
Mikuhl « Citoyen » 1375240020000
| 0 | ||
If we were to make a minigame how would we test it to see if it works? |
0 | ||
Jaackster a dit : you wouldn't |
Mikuhl « Citoyen » 1375243260000
| 0 | ||
Fxie a dit : That doesnt seem very fair. |