×

Language

Close
Atelier 801
  • Forums
  • Dev Tracker
  • Log in
    • English Français
      Português do Brasil Español
      Türkçe Polski
      Magyar Română
      العربية Skandinavisk
      Nederlands Deutsch
      Bahasa Indonesia Русский
      中文 Filipino
      Lietuvių kalba 日本語
      Suomi עברית
      Italiano Česky
      Hrvatski Slovensky
      Български Latviešu
      Estonian
  • Language
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Lua Snippets
1 / 33 › »
Lua Snippets
Mikuhl
« Citizen »
1380226680000
    • Mikuhl#3311
    • Profile
    • Last posts
    • Tribe
#1
  3
Module API:
Topic-365251

You can just copy and paste these into the tribe /lua box.

Add conjuration with mouse click said:

for name,player in pairs(tfm.get.room.playerList) do
system.bindMouse(name, true)
end

function eventMouse(name, x, y)
tfm.exec.addConjuration(x/10, y/10, 10000)
end

Add shaman object with mouse click said:

for name,player in pairs(tfm.get.room.playerList) do
system.bindMouse(name, true)
end

function eventMouse(name, x, y)
tfm.exec.addShamanObject(tfm.enum.shamanObject.littleBox, x, y, 0, 0, 0, false)
end

-- tfm.enums: http://kikoo.formice.com/doku.php?id=module_api_documentation#tfmenumshamanobject_package
-- exact enums: http://kikoo.formice.com/doku.php?id=enums#objects_anchors

Bind keyboard said:

for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.bindKeyboard(name, 70, true, true)
end

function eventKeyboard(name, key, down, x, y)
if key == 70 then
print("You pressed F at x = "..x.." and y = "..y.."!")
end
if key == 70 and down == true then
print("F is down!")
end
end

-- key codes: http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00000520.html

Send a chat message to everyone said:

for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.chatMessage("This is a message!", name)
end

-- This currently won't work, chatMessage is blocked in Tribe Houses.

Send a chat message to the Shaman said:

for name,player in pairs(tfm.get.room.playerList) do
if player.isShaman then
tfm.exec.chatMessage("This is a message!", name)
end
end

-- This currently won't work, chatMessage is blocked in Tribe Houses.

Send a chat message to everyone but the Shaman said:

for name,player in pairs(tfm.get.room.playerList) do
if not player.isShaman then
tfm.exec.chatMessage("This is a message!", name)
end
end

-- This currently won't work, chatMessage is blocked in Tribe Houses.

Kiss for cheese said:

function eventEmotePlayed(playerName,emote)
if emote==3 then
tfm.exec.giveCheese(playerName)
end
end

-- emote IDs: http://kikoo.formice.com/doku.php?id=enums#emoticons

Give everyone Meep said:

for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.giveMeep(name)
end

Mort said:

function eventChatCommand(name,command)
if command=="mort" then
tfm.exec.killPlayer(name)
end
end

Move player with mouse click said:

for name,player in pairs(tfm.get.room.playerList) do
system.bindMouse(name, true)
end

function eventMouse(name, x, y)
tfm.exec.movePlayer(name, x, y, false, 0, 1, false)
end

Respawn Player said:

function eventPlayerDied(name)
tfm.exec.respawnPlayer(name)
end

[quote=Keep game time at 0:00]
tfm.exec.disableAutoNewGame(true)
tfm.exec.setGameTime(0)
[/quote]

[quote=Set name color (replace my name with yours, and ffffff with the hex code)]
tfm.exec.setNameColor("Jaackster", 0xffffff)
[/quote]

Give everyone a random name color said:

for name, player in pairs(tfm.get.room.playerList) do
tfm.exec.setNameColor(name, string.format("%x", math.random(0x000000, 0xFFFFFF)))
end

[quote=Make everyone a Shaman (Object spawning is bugged.)]
for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.setShaman(name)
end
[/quote]

Make everyone a Vampire said:

for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.setVampirePlayer(name)
end

Make a random player a Vampire said:

players = {}
for name,player in pairs(tfm.get.room.playerList) do
table.insert(players,name)
end
tfm.exec.setVampirePlayer(players[math.random(#players)])

Make everyone a Shampire said:

for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.setShaman(name)
tfm.exec.setVampirePlayer(name)
end

Make the shaman a Vampire by Shamousey said:

function eventNewGame()
for name,player in pairs(tfm.get.room.playerList) do
if player.isShaman then
tfm.exec.setVampirePlayer(name)
end
end
end

Set UI text said:

tfm.exec.setUIMapName("Map Name")
tfm.exec.setUIShamanName("Shaman Name")

Make it snow said:

tfm.exec.snow()

Eternal Snow by Makinit said:

tfm.exec.snow()

local loopCount = 0
function eventLoop()
if loopCount == 0 then
tfm.exec.snow()
tfm.exec.snow()
end
loopCount = (loopCount + 1) % 100
end

ADVANCED SNIPPETS:

[quote=Fly (Space) by Shamousey]
function eventNewPlayer(name)
tfm.exec.bindKeyboard(name,32,true,true)
end

for name,player in pairs(tfm.get.room.playerList) do
eventNewPlayer(name)
end

function eventKeyboard(name,key,down,x,y)
if key==32 then
tfm.exec.movePlayer(name,0,0,true,0,-50,false)
end
end
[/quote]

Simple Command said:

function eventChatCommand(name, cmd)
if cmd:sub(0,3) == "map" then
tfm.exec.newGame(cmd:sub(5))
end
end

-- cmd:sub(0,3) checks if the first 3 characters are 'map'
-- cmd:sub(5) uses anything after, and including the 5th character, like a map code. !map @666666

Advanced Command said:

function eventChatCommand(name, cmd)
local cmd_args = {}
for arg in cmd:gmatch("[^%s]+") do -- splits the command by spaces.
table.insert(cmd_args, arg) -- inserts them into the table
end
if cmd_args[1] == "color" then -- checks if the first word in the table is color
tfm.exec.setNameColor(cmd_args[2], tonumber("0x"..cmd_args[3])) -- uses the second argument as a name, and the third as a hex code.
end
end

makeTeams by Fxie said:

red={}
blue={}
function makeTeams()
local playerList={}
for name,player in pairs(tfm.get.room.playerList) do
table.insert(playerList,name)
end
for i=1,#playerList,1 do
local index=math.random(#playerList)
local name=playerList[index]
if i%2==0 then
table.insert(red,name)
else
table.insert(blue,name)
end
table.remove(playerList,index)
end
end

Last edit on 1412280240000
Epicshawty
« Citizen »
1380226800000
    • Epicshawty#0000
    • Profile
    • Last posts
    • Tribe
#2
  0
thxz yo
Irishcow
« Citizen »
1380226920000
    • Irishcow#0095
    • Profile
    • Last posts
    • Tribe
#3
  0
Credits to Shamousey :)
Mouse fly:


function eventNewPlayer(name)
tfm.exec.bindKeyboard(name,32,true,true)
end
for name,player in pairs(tfm.get.room.playerList) do
eventNewPlayer(name)
end
function eventKeyboard(name,key,down,x,y)
if key==32 then tfm.exec.movePlayer(name,0,0,true,0,-50,false)
end
end
Enginfener
« Citizen »
1380227160000
    • Enginfener#0000
    • Profile
    • Last posts
    • Tribe
#4
  1
Oh ty Jaackster
Shamousey
« Consul »
1380227160000
    • Shamousey#0095
    • Profile
    • Last posts
    • Tribe
#5
  2
Irishcow said:
I'm not sure where my tribe got this (Tig's original Thread most likely) but here's the code for mice to fly.

I'd passed that in /chat Lua so that a few people could learn from it ;)

If anyone else wants some specific code snippets then feel free to ask!
Irishcow
« Citizen »
1380227580000
    • Irishcow#0095
    • Profile
    • Last posts
    • Tribe
#6
  0
Shamousey said:
I'd passed that in /chat Lua so that a few people could learn from it ;)

Ah ok, thanks!
Jaackster said:

Make everyone a Shaman (Spawning may be buggy):
for name,player in pairs(tfm.get.room.playerList) do
tfm.exec.setShaman(name)
end

Anyway someone could integrate shaman skills in this script? Would be pretty cool
Mikuhl
« Citizen »
1380227700000
    • Mikuhl#3311
    • Profile
    • Last posts
    • Tribe
#7
  0
Irishcow said:
Anyway someone could integrate shaman skills in this script? Would be pretty cool

Impossible, this may or may not be a bug with the setShaman.
Enginfener
« Citizen »
1380227700000
    • Enginfener#0000
    • Profile
    • Last posts
    • Tribe
#8
  1
said:
Instant respawn said eventPlayerDied function (playername)
tfm.exec.respawnPlayer (playername)
end

Freeze mouse gets the cheese when he said: function eventPlayerGetCheese (playername)
tfm.exec.killPlayer (playername)
tfm.exec.addShamanObject(tfm.enum.shamanObject.iceCube,tfm.get.room.playerList[playerName].x,tfm.get.room.playerList[playerName].y)
end

Summon 2 balls randomly by the X axis of the map every 500 milliseconds said eventLoop function ()
1,2,1 is the tfm.exec.addShamanobject (6, math.random (1,799), 100) end
end

Help command said eventChatCommand function (playername, command)
if command == "help" then
tfm.exec.chatMessage ("<J> Here is some help for you!", playername)
end
end

Greet one played when he enters the room said eventNewPlayer function (playername)
tfm.exec.chatMessage ("<J> Welcome to this minigame amazing!", playername)
end

Kill everyone with cheese said for playername, player in pairs (tfm.get.room.playerList) of
then if player.hasCheese
tfm.exec.killPlayer (playername)
end
end

Flying while holding space said eventNewGame function ()
playername is in pairs (tfm.get.room.playerList) of
tfm.exec.bindKeyboard (playername, 32, true)
end
end
eventKeyboard function (playername, keyCode)
if keyCode == 32 then
tfm.exec.movePlayer (p, 0.0, true, 0, -50, true)
end
end


........ command
Jordy
« Consul »
1380227940000
    • Jordy#0015
    • Profile
    • Last posts
    • Tribe
#9
  0
^ That script will not work in your tribe house. Because you can't use "tfm.exec.chatMessage".
Neither do you comment your text.
If you want to comment something in your script add "--" before it.
Eclair
« Citizen »
1380228060000
    • Eclair#2002
    • Profile
    • Last posts
    • Tribe
#10
  0
Thanks, Jack. :)
Gilcatmey
« Citizen »
1380229620000
    • Gilcatmey#0000
    • Profile
    • Last posts
    • Tribe
#11
  0
Thanks :D
Hatoncat
« Citizen »
1380234240000
    • Hatoncat#0000
    • Profile
    • Last posts
    • Tribe
#12
  0
Well, I've 'mastered' map making, before they fucked up all of the glitches. Guess it's time for me to tackle Lua.
Fourchin
« Citizen »
1380236400000
    • Fourchin#0000
    • Profile
    • Last posts
    • Tribe
#13
  0
Fly lua gave me activity suspecte three times in a row. No actual ban, just a kick.
Lightningwx
« Citizen »
1380241380000
    • Lightningwx#0000
    • Profile
    • Last posts
    • Tribe
#14
  0
still have no idea ...
Hatoncat
« Citizen »
1380241920000
    • Hatoncat#0000
    • Profile
    • Last posts
    • Tribe
#15
  0
Fourchin said:
Fly lua gave me activity suspecte three times in a row. No actual ban, just a kick.

Don't jump while using it. Just use the spacebar only.
Xanmeow
« Citizen »
1380242040000
    • Xanmeow#0000
    • Profile
    • Last posts
    • Tribe
#16
  0
can you make a script that makes it say this:

when you type !Xanmeow this happens: Xanmeow has a message! He says! MEOW AND HI!!! :D
Hatoncat
« Citizen »
1380242400000
    • Hatoncat#0000
    • Profile
    • Last posts
    • Tribe
#17
  0
said:
can you make a script that makes it say this:

when you type !Xanmeow this happens: Xanmeow has a message! He says! MEOW AND HI!!! :D

Copy and paste this:
said:
print("Xanmeow has a message! He says MEOW AND HI!!! :D"

You can alter that in any way you want, as long as you only alter what is inside of the quatations.
Shamousey
« Consul »
1380242760000
    • Shamousey#0095
    • Profile
    • Last posts
    • Tribe
#18
  0
Xanmeow said:
can you make a script that makes it say this:

when you type !Xanmeow this happens: Xanmeow has a message! He says! MEOW AND HI!!! :D

function eventChatCommand(name,command)
print(command.." has a message! He says MEOW AND HI!!! :D")
end
Hatoncat
« Citizen »
1380243420000
    • Hatoncat#0000
    • Profile
    • Last posts
    • Tribe
#19
  0
Shamousey, will you ever make a Tfm/Lua guide? I've been reading up on it, but trying to mix the two can be kind of tough.
Shamousey
« Consul »
1380243420000
    • Shamousey#0095
    • Profile
    • Last posts
    • Tribe
#20
  0
Hatoncat said:
Shamousey, will you ever make a Tfm/Lua guide? I've been reading up on it, but trying to mix the two can be kind of tough.

I'm writing one right now!
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Lua Snippets
1 / 33 › »
© Atelier801 2018

Staff Terms and Conditions of Use Privacy Policy Contact

Version 1.27