×

Langue

Fermer
Atelier 801
  • Forums
  • Dev Tracker
  • Connexion
    • 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
  • Langue
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Lua Snippets
1 / 33 › »
Lua Snippets
Mikuhl
« Citoyen »
1380226680000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#1
  3
Module API:
Topic-365251

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

Add conjuration with mouse click a dit :

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 a dit :

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 a dit :

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 a dit :

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 a dit :

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 a dit :

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 a dit :

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 a dit :

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

Mort a dit :

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

Move player with mouse click a dit :

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 a dit :

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 a dit :

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 a dit :

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

Make a random player a Vampire a dit :

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 a dit :

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 a dit :

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 a dit :

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

Make it snow a dit :

tfm.exec.snow()

Eternal Snow by Makinit a dit :

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 a dit :

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 a dit :

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 a dit :

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

Dernière modification le 1412280240000
Epicshawty
« Citoyen »
1380226800000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#2
  0
thxz yo
Irishcow
« Citoyen »
1380226920000
    • Irishcow#0095
    • Profil
    • Derniers messages
    • Tribu
#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
« Citoyen »
1380227160000
    • Enginfener#0000
    • Profil
    • Derniers messages
    • Tribu
#4
  1
Oh ty Jaackster
Shamousey
« Consul »
1380227160000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#5
  2
Irishcow a dit :
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
« Citoyen »
1380227580000
    • Irishcow#0095
    • Profil
    • Derniers messages
    • Tribu
#6
  0
Shamousey a dit :
I'd passed that in /chat Lua so that a few people could learn from it ;)

Ah ok, thanks!
Jaackster a dit :

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
« Citoyen »
1380227700000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#7
  0
Irishcow a dit :
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
« Citoyen »
1380227700000
    • Enginfener#0000
    • Profil
    • Derniers messages
    • Tribu
#8
  1
a dit :
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
    • Profil
    • Derniers messages
    • Tribu
#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
« Citoyen »
1380228060000
    • Eclair#2002
    • Profil
    • Derniers messages
    • Tribu
#10
  0
Thanks, Jack. :)
Gilcatmey
« Citoyen »
1380229620000
    • Gilcatmey#0000
    • Profil
    • Derniers messages
    • Tribu
#11
  0
Thanks :D
Hatoncat
« Citoyen »
1380234240000
    • Hatoncat#0000
    • Profil
    • Derniers messages
    • Tribu
#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
« Citoyen »
1380236400000
    • Fourchin#0000
    • Profil
    • Derniers messages
    • Tribu
#13
  0
Fly lua gave me activity suspecte three times in a row. No actual ban, just a kick.
Lightningwx
« Citoyen »
1380241380000
    • Lightningwx#0000
    • Profil
    • Derniers messages
    • Tribu
#14
  0
still have no idea ...
Hatoncat
« Citoyen »
1380241920000
    • Hatoncat#0000
    • Profil
    • Derniers messages
    • Tribu
#15
  0
Fourchin a dit :
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
« Citoyen »
1380242040000
    • Xanmeow#0000
    • Profil
    • Derniers messages
    • Tribu
#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
« Citoyen »
1380242400000
    • Hatoncat#0000
    • Profil
    • Derniers messages
    • Tribu
#17
  0
a dit :
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:
a dit :
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
    • Profil
    • Derniers messages
    • Tribu
#18
  0
Xanmeow a dit :
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
« Citoyen »
1380243420000
    • Hatoncat#0000
    • Profil
    • Derniers messages
    • Tribu
#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
    • Profil
    • Derniers messages
    • Tribu
#20
  0
Hatoncat a dit :
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

Equipe Conditions Générales d'Utilisation Politique de Confidentialité Contact

Version 1.27