×

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
« ‹ 15 / 33 › »
Lua Snippets
Xxninjazxx
« Citoyen »
1380537060000
    • Xxninjazxx#0000
    • Profil
    • Derniers messages
#281
  0
Can someone do:

2 shamans

custom map rotation

give everyone except the shaman meeps
Jordy
« Consul »
1380537180000
    • Jordy#0015
    • Profil
    • Derniers messages
    • Tribu
#282
  0
Xxninjazxx a dit :
Can someone do:

2 shamans

custom map rotation

give everyone except the shaman meeps

You have to give us some more information about the custom map rotation.
Xxninjazxx
« Citoyen »
1380537180000
    • Xxninjazxx#0000
    • Profil
    • Derniers messages
#283
  0
if you show me an example I can figure it out myself...
Jordy
« Consul »
1380539220000
    • Jordy#0015
    • Profil
    • Derniers messages
    • Tribu
#284
  0
Xxninjazxx a dit :
if you show me an example I can figure it out myself...

Try this.

a dit :

maps = {'@map1', '@map2', '@map3'}

function table.random(t, associative)
associative = associative or false
if associative then
local t2 = {}
for k in pairs(t) do
t2[#t2 + 1] = k
end
return t[table.random(t2)]
else
return t[math.random(1,#t)]
end
end

function table.len(t)
local i = 0
for n in pairs(t) do
i = i + 1
end
return i
end

function eventLoop(time, remainingtime)
if table.len(tfm.get.room.playerList) ~= 1 then
if remainingtime <= 0 then
tfm.exec.newGame(maps[math.random(#maps)])
end
end
end

function eventNewGame()
roomPlayers = {}
shaman1 = table.random(tfm.get.room.playerList,true).playerName
shaman2 = table.random(tfm.get.room.playerList,true).playerName
for name,player in pairs(tfm.get.room.playerList) do
table.insert(roomPlayers, name)
roomPlayers[name] = true
end
roomPlayers[shaman1] = false
roomPlayers[shaman2] = false
table.remove(roomPlayers, shaman1)
table.remove(roomPlayers, shaman2)
for name,meep in pairs(roomPlayers) do
if meep then
tfm.exec.giveMeep(name)
end
end
end
Shamousey
« Consul »
1380539340000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#285
  0
Alternatively to Jordy's version, you can try this.

a dit :
--Do this every new round.
function eventNewGame()
--Check if there are at least 2 players to make a shaman,
if table.count(tfm.get.room.playerList)>=2 then
--While there are less than two shamans, make someone a shaman.
while table.count(tfm.get.room.playerList,"isShaman")<2 do
--Pick a random player and make them a shaman.
tfm.exec.setShaman(table.random(tfm.get.room.playerList,true).playerName)
end
--If there aren't two or mroe players in the room, do this.
else
--Make a random person shaman.
tfm.exec.setShaman(table.random(tfm.get.room.playerList,true).playerName)
end
--Loop through everyone in the room.
for name,players in pairs(tfm.get.room.playerList) do
--If the player isn't a shaman...
if not player.isShaman then
--...give them meep.
tfm.exec.giveMeep(name)
end
end
end

--Counts the amount of elements in an associative table
function table.count(tbl,subtbl)
local i=0
if subtbl then
for k,v in pairs(tbl) do
if v[subtbl] then i=i+1 end
end
else
for _ in pairs(tbl) do i=i+1 end
end
return i
end

--Selects a random element from a table.
function table.random(t,associative)
associative=associative or false
if associative then
local t2={}
for k in pairs(t) do
t2[#t2+1]=k
end
return t[table.random(t2)]
else
return t[math.random(1,#t)]
end
end

 
Mapsych
« Citoyen »
1380553680000
    • Mapsych#0000
    • Profil
    • Derniers messages
    • Tribu
#286
  0
Is there any juntor Lua, is only 2 in 1 scripts? xD
Ex: It takes 2 scripts attached as 1 only.

@GoogleTranslator
Shamousey
« Consul »
1380555720000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#287
  0
Mapsych a dit :
Is there any juntor Lua, is only 2 in 1 scripts? xD
Ex: It takes 2 scripts attached as 1 only.

@GoogleTranslator

That's very hard to understand, but you can easily put two scripts into one by copying & pasting the right bits of code, making sure you don't redefine any functions it uses.
Cincle
« Citoyen »
1380557400000
    • Cincle#0000
    • Profil
    • Derniers messages
    • Tribu
#288
  0
Hi I tried this script:
function eventChatCommand(name,command)if command=="mort" thentfm.exec.killPlayer("Cincle")endend
Why it is not working ?
Shamousey
« Consul »
1380557820000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#289
  0
Your text is all on one line and causing some issues. For example "then tfm.exec..." has become "thentfm.exec..." which isn't valid. The same with "end end" being "endend". Try putting a space between these things, or using this below.

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

 
Hophipmice
« Citoyen »
1380557940000
    • Hophipmice#0000
    • Profil
    • Derniers messages
    • Tribu
#290
  0
Cincle a dit :
Hi I tried this script:
function eventChatCommand(name,command)if command=="mort" thentfm.exec.killPlayer("Cincle")endend
Why it is not working ?

because that would kill the player cincle and because thentf.exec.killPlayer isn't vaild.


try

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

Edit: Ninja.
Cincle
« Citoyen »
1380558060000
    • Cincle#0000
    • Profil
    • Derniers messages
    • Tribu
#291
  0
Shamousey a dit :
Your text is all on one line and causing some issues. For example "then tfm.exec..." has become "thentfm.exec..." which isn't valid. The same with "end end" being "endend". Try putting a space between these things, or using this below.

 

Hophipmice a dit :
because that would kill the player cincle and because thentf.exec.killPlayer isn't vaild.


try

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

Thanks both! :)
Mapsych
« Citoyen »
1380558180000
    • Mapsych#0000
    • Profil
    • Derniers messages
    • Tribu
#292
  1
Shamousey a dit :
That's very hard to understand, but you can easily put two scripts into one by copying &amp; pasting the right bits of code, making sure you don't redefine any functions it uses.

Well, i'll show you:

Script1 a dit :
function eventNewPlayer(name)
for i,key in ipairs({83,40,69}) do
tfm.exec.bindKeyboard(name,key,true,true)
end
end

function eventKeyboard(name,key,down,x,y)
if key==83 or key==40 or key==69 then
tfm.exec.movePlayer(name,0,0,true,0,-50,true)
end
end

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

Script2 a dit :
function eventNewPlayer(name)
for i,key in ipairs({83,40,69}) do
tfm.exec.bindKeyboard(name,key,true,true)
end
end

function eventKeyboard(name,key,down,x,y)
if key==83 or key==40 or key==69 then
if tfm.get.room.playerList[name].isFacingRight then
tfm.exec.addShamanObject(10,x,y)
else
tfm.exec.addShamanObject(10,x,y)
end
end
end

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

Script 1 + Script 2 together :p
Hophipmice
« Citoyen »
1380558420000
    • Hophipmice#0000
    • Profil
    • Derniers messages
    • Tribu
#293
  0
Cincle a dit :
And If I can ask,how to make all players to use !mort command? :3

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

^^^^ that.
Cincle
« Citoyen »
1380558420000
    • Cincle#0000
    • Profil
    • Derniers messages
    • Tribu
#294
  0
And If I can ask,how to make all players to use !mort command? :3
Cincle
« Citoyen »
1380558540000
    • Cincle#0000
    • Profil
    • Derniers messages
    • Tribu
#295
  0
Hophipmice a dit :
function eventChatCommand(name,command)
if command=="mort" then
tfm.exec.killPlayer(name)
end
end

^^^^ that.

Thank you. ^_^

And now if I can ask - What's the respawn script? :3
Cincle
1380559320000
    • Cincle#0000
    • Profil
    • Derniers messages
    • Tribu
#296
[Modéré par Katburger, raison : Please don't double post!]
Tailtong
« Citoyen »
1380560460000
    • Tailtong#0000
    • Profil
    • Derniers messages
    • Tribu
#297
  0
Cincle a dit :
And now if I can ask - What's the respawn script? :3

as a command :
a dit :
function eventChatCommand(p,c)
if c=="your command name here" then
tfm.exec.respawnPlayer(p)
end
end

should work, idk, i improvised it
Hophipmice
« Citoyen »
1380560460000
    • Hophipmice#0000
    • Profil
    • Derniers messages
    • Tribu
#298
  0
Cincle a dit :
And now if I can ask - What's the respawn script? :3

For command or when somebody dies and respawns straight away?

for respawning command:

a dit :
function evenChatCommand(name,command)
if command=="respawn" then
tfm.exec.respawnPlayer(name)
end
end

If somebody dies then respawn then:
a dit :
function eventPlayerDied(name)
tfm.exec.respawnPlayer(name)
end

IF YOU ALREADY HAVE A COMMAND SET UP THEN UNDER THAT COMMAND, BEFORE END DO:

a dit :
elseif command=="respawn" then
tfm.exec.respawnPlayer(name)

Ninja, but mine, better...
Byenamo
« Citoyen »
1380564840000
    • Byenamo#0000
    • Profil
    • Derniers messages
    • Tribu
#299
  0
As I Usso key with vamp and fly?
Ethanrockz
« Citoyen »
1380565320000
    • Ethanrockz#0000
    • Profil
    • Derniers messages
    • Tribu
#300
  0
How do you make it so only one person can use commands like if i did !Roseyissweet she would die but if she did !Ethanrockz it wont work
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Lua Snippets
« ‹ 15 / 33 › »
© Atelier801 2018

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

Version 1.27