×

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
  • /
  • Archives
  • /
  • Module API FAQ
« ‹ 8 / 38 › »
Module API FAQ
Mikuhl
« Citoyen »
1378341480000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#141
  0
Bigcrushes a dit :
http://pastebin.com/ZmVVumfx

*cringe*
Bigcrushes
« Citoyen »
1378367700000
    • Bigcrushes#0000
    • Profil
    • Derniers messages
    • Tribu
#142
  0
Jaackster a dit :
*cringe*

are u from lua? did u test meh script? it failed didnt it
Moepl
« Citoyen »
1378392780000
    • Moepl#0095
    • Profil
    • Derniers messages
#143
  0
Bigcrushes a dit :
are u from lua? did u test meh script? it failed didnt it

Jaackster is not in the lua group as far as I know.

About your script (I didn't test it either but I'll mention some things I saw after looking at it):
- line 8: tfm.exec.killPlayer is a function: e.g do tfm.exec.killPlayer(playerName)
- similiar on line 10 and 17
- line 15 and 19: functions don't work like that in lua.

You might want to try to write some simple lua code first before doing transformice scripts
Check this out: http://www.lua.org/cgi-bin/demo
Bigcrushes
« Citoyen »
1378393800000
    • Bigcrushes#0000
    • Profil
    • Derniers messages
    • Tribu
#144
  0
Moepl a dit :
Jaackster is not in the lua group as far as I know.

About your script (I didn't test it either but I'll mention some things I saw after looking at it):
- line 8: tfm.exec.killPlayer is a function: e.g do tfm.exec.killPlayer(playerName)
- similiar on line 10 and 17
- line 15 and 19: functions don't work like that in lua.

You might want to try to write some simple lua code first before doing transformice scripts
Check this out: http://www.lua.org/cgi-bin/demo

thx moepl, my friend has made an editted version that works already of my script. I have a lot of work to do ._. thx for the website
Epicshawty
« Citoyen »
1378413780000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#145
  0
Does this make everyone shaman in a new round?
a dit :

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

I'm a beginner.
Thewav
« Citoyen »
1378413900000
    • Thewav#0095
    • Profil
    • Derniers messages
    • Tribu
#146
  0
Yes but need end to close the for loop
Epicshawty
« Citoyen »
1378414080000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#147
  0
Thewav a dit :
Yes but need end to close the for loop

where do i put that?
just make an example so i know :P
Shamousey
« Consul »
1378414080000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#148
  0
You need to end both the function and the for loop, just make sure there's an end for each of them.
Epicshawty
« Citoyen »
1378414200000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#149
  0
Shamousey a dit :
You need to end both the function and the for loop, just make sure there's an end for each of them.

Oh, okay.
Fxie
« Citoyen »
1378417140000
    • Fxie#0000
    • Profil
    • Derniers messages
    • Tribu
#150
  0
that's one of the more annoying bits of lua not using conventional curly braces.
Epicshawty
« Citoyen »
1378417260000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#151
  0
that part where you cant find in the module api documentation on how to make the last person standing win
lel
Fxie
« Citoyen »
1378417500000
    • Fxie#0000
    • Profil
    • Derniers messages
    • Tribu
#152
  0
function eventPlayerDied()
> local winner
> for name,player in pairs(tfm.get.room.playerList) do
> > if not player.isDead then
> > > if not winner then
> > > > winner=name
> > > else
> > > > return
> > > > end
> > > end
> > end
> tfm.exec.chatMessage(winner.." is the last person standing!")
> end

basically abort the function (return) if there are two people alive (another winner after one has been found), if there is only one winner then their name is set and yo ucan use it for whatever.
Mikuhl
« Citoyen »
1378420860000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#153
  0
Bigcrushes a dit :
are u from lua? did u test meh script? it failed didnt it

Im not in the lua team yet. (Hopefully I will be soon!)
Epicshawty
« Citoyen »
1378432980000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#154
  0
Jaackster a dit :
Im not in the lua team yet. (Hopefully I will be soon!)

me too lel
Fxie
« Citoyen »
1378435560000
    • Fxie#0000
    • Profil
    • Derniers messages
    • Tribu
#155
  0
samei cant wait
Epicshawty
« Citoyen »
1378438500000
    • Epicshawty#0000
    • Profil
    • Derniers messages
    • Tribu
#156
  0
Fxie a dit :
samei cant wait

lezz celebr8
Bigcrushes
« Citoyen »
1378439040000
    • Bigcrushes#0000
    • Profil
    • Derniers messages
    • Tribu
#157
  0
Epicshawty a dit :
lezz celebr8

i wanna celebr8 too!

Can someone pls gimme the lua code to split mice into teams?
Fxie
« Citoyen »
1378469760000
    • Fxie#0000
    • Profil
    • Derniers messages
    • Tribu
#158
  0
local players={}
local teams={{},{},{}}
for name,player in pairs(tfm.get.room.playerList) do
> table.insert(players,name)
> end
table.sort(players,function() return math.random()>0.5 end)
for i,player in ipairs(players) do
> table.insert(teams[i%#teams],player)
> end

this will give you 3 teams of random people
you can just keep adding to the team objects for more or remove for less

teams[1], teams[2], teams[3], etc. are your teams

teams[1] = [ "Fxie", "Someone else", "So on"]
teams[2] = [ "You", "Bigcrushes", "Souris"]
teams[3] = [ "Rad", "Ical", "Sillyputty"]


i obviously can't test this but it should work even though I just wrote it on the spot.
Bigcrushes
« Citoyen »
1378471260000
    • Bigcrushes#0000
    • Profil
    • Derniers messages
    • Tribu
#159
  0
Fxie a dit :
local players={}
local teams={{},{},{}}
for name,player in pairs(tfm.get.room.playerList) do
> table.insert(players,name)
> end
table.sort(players,function() return math.random()>0.5 end)
for i,player in ipairs(players) do
> table.insert(teams[i%#teams],player)
> end

this will give you 3 teams of random people
you can just keep adding to the team objects for more or remove for less

teams[1], teams[2], teams[3], etc. are your teams

teams[1] = [ "Fxie", "Someone else", "So on"]
teams[2] = [ "You", "Bigcrushes", "Souris"]
teams[3] = [ "Rad", "Ical", "Sillyputty"]


i obviously can't test this but it should work even though I just wrote it on the spot.

ty *-* i thot u in lua? why cant u test it? and i never knew "%#" were used in lua :o got a lot to learn....
Fxie
« Citoyen »
1378471920000
    • Fxie#0000
    • Profil
    • Derniers messages
    • Tribu
#160
  0
To get the number of items in an index table (table={1,2,3}) you use #table

So if you make the table
players = { "Me", "Myself", "I" }

then #players will be 3

% is modulus, it gives you the remainder of a/b. You don't really need to know that to do basic stuff in Lua, it's more "advanced." Don't worry yourself with it until you have the basics down.
  • Forums
  • /
  • Transformice
  • /
  • Archives
  • /
  • Module API FAQ
« ‹ 8 / 38 › »
© Atelier801 2018

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

Version 1.27