×

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
  • /
  • Function Library
1 / 3 › »
Function Library
Shamousey
« Consul »
1381174140000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#1
  0
This thread contains a library of general functions that can be used in Lua to extend its functionality. Some can be used to extend the tfm. package in the Module API, and some are general Lua functions that can be used for different purposes.

http://i.imgur.com/4vSFf.png

http://i.imgur.com/TSIfr54.png
The functions in this section extend the table library.

table.count
Returns the number of items in an associative table. Useful because #table can't be used on associative tables.
a dit :
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

table.random
Returns a random value from a table.
a dit :
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

table.contains
Returns true or false, based on whether a value is located within a table.
a dit :
function table.contains(t,element)
if element==nil then
return false
end
for key,value in pairs(t) do
if value==element then
return true
end
end
return false
end

table.invert
Inverts the key and value of a table.
a dit :
function table.invert(t)
local u = { }
for k, v in pairs(t) do u[v] = k end
return u
end

table.keys
Returns an indexed list of keys in a table.
a dit :
function table.keys(t)
local t2 = {}
for k in pairs(t) do
table.insert(t2, k)
end
return t2
end

table.copy
Returns a deep or shallow copy of a table.
a dit :
function table.copy(t, d)
d = d or false
local t2 = {}
for k, v in pairs(t) do
if d then
if type(k) == "table" then
k = table.copy(k, true)
end
if type(v) == "table" then
v = table.copy(v, true)
end
end
t2[k] = v
end
return t2
end

table.unpack
Returns a tuple (multiple return variables) that are in a given table.
This is now a default function in Lua and doesn't need to be additionally defined.
a dit :
function table.unpack(t, i)
i = i or 1
if not (t == nil) then
return t, unpack(t, i + 1)
end
end

http://i.imgur.com/4vSFf.png

http://i.imgur.com/hZmC22h.png
This section includes functions that extend the string library

string.split
Splits a string into separate elements in a table.
a dit :
function string.split(str,s)
local res = {}
for part in string.gmatch(str, "[^" .. s .. "]+") do
table.insert(res, part)
end
return res
end

string.contains
Returns whether a substring is found in another string
a dit :
function string.contains(str,substr)
return not (str:find(substr) == nil)
end

string.prefix
Returns whether a string starts with a substring
a dit :
function string.prefix(str, substr)
return (str:sub(1, substr:len()) == substr)
end

http://i.imgur.com/4vSFf.png

http://i.imgur.com/DczZ5BV.png
randomColor
Returns a random HEX colour code.
a dit :
function randomColor()
return string.format("%X", math.random(0x000000, 0xFFFFFF))
end

printTable
Prints all of the information inside a table.
a dit :
function printTable(tbl)
if tbl then
for k,v in pairs(tbl) do
if type(v) == 'table' then
print('<N>'..k..' (table): ')
printTable(v)
else
v = tostring(v)
print(k..': '..v)
end
end
end
end

stringtotable
Changes a string to a table.
a dit :
function stringtotable(str, tblopen, tblclose, separate, whatdoicallthis)
tblopen = tblopen or "{"
tblclose = tblclose or "}"
separate = separate or "$"
whatdoicallthis = whatdoicallthis or "="
str = str:sub(2,str:len()-1)

local indexed = string.split(str,separate)
local ans = {}
local counter = 0
local concat = ""
local tablekey = ""

if #indexed == 1 then
local t = string.split(str, whatdoicallthis)
if #t == 2 then
ans[t[1]] = t[2]
else
ans[#ans+1] = v
end
return ans
end

for k,v in pairs(indexed) do
if counter == 0 then
if v:find(tblopen) then
local t = string.split(v,tblopen)
if t[1]:find(whatdoicallthis) then
concat = ""
for i=2,#t do
concat = concat..tblopen..t
end
tablekey = t[1]:sub(1,t[1]:len()-whatdoicallthis:len())
else
tablekey = #ans+1
concat = v
end
if v:find(tblclose) then
ans[tablekey] = stringtotable(concat, tblopen, tblclose, separate, whatdoicallthis)
else
counter = 1
end
else
local t = string.split(v, whatdoicallthis)
if #t == 2 then
ans[t[1]] = t[2]
else
ans[#ans+1] = v
end
print(v)
end
else
for i=1, v:len() do
local s = v:sub(i,i)
if s:find(tblopen) then
counter = counter + 1
end
if s:find(tblclose) then
counter = counter - 1
end
end
concat = concat..separate..v
if counter == 0 then
ans[tablekey] = stringtotable(concat, tblopen, tblclose, separate, whatdoicallthis)
end
end
end

return ans
end

tabletostring
Changes a table into a string.
a dit :
function tabletostring(tbl, tblopen, tblclose, separate, whatdoicallthis)
tblopen = tblopen or "{"
tblclose = tblclose or "}"
separate = separate or "$"
whatdoicallthis = whatdoicallthis or "="

local str = tblopen
for k,v in pairs(tbl) do
if type(v) == 'table' then
str = str..tostring(k)..whatdoicallthis..tabletostring(v,tblopen,tblclose,separate,whatdoicallthis)..separate
else
str = str..tostring(k)..whatdoicallthis..tostring(v)..separate
end
end
str = str:sub(1,str:len()-separate:len())
return str..tblclose
end

pythag
Detects if two points are within a radius of eachother.
a dit :
function pythag(x1,y1,x2,y2,r)
local x=x2-x1
local y=y2-y1
local r=r+r
return x*x+y*y<r*r
end

 

Dernière modification le 1429913820000
Shamousey
« Consul »
1381174140000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#2
  0
http://i.imgur.com/mVvl7hl.png
tfm.exec.newGame("#V")
Vanilla maps work as #V in tfm.exec.newGame()
a dit :
newgame=tfm.exec.newGame
function tfm.exec.newGame(map)
if map=="#V" then
local vanilla={} for x=0,143 do table.insert(vanilla,x) end for x=200,210 do table.insert(vanilla, x) end
newgame(vanilla[math.random(#vanilla)])
else
newgame(map)
end
end

tfm.exec.giveWin
Makes a player win (instead of running two separate functions each time).
a dit :
function tfm.exec.giveWin(name)
tfm.exec.giveCheese(name)
tfm.exec.playerVictory(name)
end

tfm.exec.giveWinAll
Makes everyone in the room win.
a dit :
function tfm.exec.giveWinAll()
for name,player in pairs(tfm.get.room.playerList) do
if not player.isDead then
giveWin(name)
end
end
end

http://i.imgur.com/4vSFf.png

http://i.imgur.com/Si4Zyd6.png
tfm.get.room.shaman
Returns the shaman's name. Requires table.unpack
a dit :
function tfm.get.room.shaman()
local shamans = {};
for name,player in pairs(tfm.get.room.playerList) do
if player.isShaman then
table.insert(shamans,name)
end
end
return table.unpack(shamans)
end

tfm.get.room.alive
Returns a list of players who are alive.
a dit :
function tfm.get.room.alive()
local alivePlayers={}
for name,player in pairs(tfm.get.room.playerList) do
if not player.isDead then
table.insert(alivePlayers, name)
end
end
return alivePlayers
end

http://i.imgur.com/4vSFf.png

http://i.imgur.com/5KMhANA.png
tfm.get.misc.admins
Returns a list of administrators.
a dit :
tfm.get.misc.admins={
"Tigrounette","Melibellule","Sydoline","Ley","Loukno","Azrou","Galaktine","Khuikhui","Maharadjah","Merope","Mickaelsan","Narayan"
}

tfm.get.misc.mods
Returns a list of moderators by community.
a dit :
tfm.get.misc.mods={
en={"Amavauno","Caitybumz","Chrisbeer","Devhyn","Fatpandas","Flipgraham","Harrytrotter","Harshy","Helmivene","Katburger","Momokolee","Rype","Snarb","Tetsuro","Verkon"},
br={"Coleandro","Modhehehe","Modnis","Randomod","Roflzor","Sramod"},
fr={"Aewing","Cryquinette","Faraday","Korsakofff","Meoxie","Modoflore","Modoloris","Modomaya","Modonoodle","Modopops","Modorate","Modoxide","Modozap","Modozore","Pheicas","Pikashu","Thihtx","Violainator","Yoshun"},
tr={"Artcore","Deamaus","Gizlimod","Hyypno","Kingviking","Larten","Nehirr","Raraavis","Shebnem"},
ru={"Denezhki","Gubki","Minamur","Muthabor","Nogotki","Nuliki","Plyushki"},
es={"Ablebuci","Arsinoa","Asymptotee","Bunniesmod","Levols","Modogrande","Shyraa"},
cn={"Anyo","Fatpandas","Klauszhang","Momokolee","Piratearthur","Plkzc","Xiezi"},
vk={"Alvanista","Cleyra","Helmivene","Modblomma","Pepperkake"},
nl={},
pl={"Laracerindar"},
hu={"Minnera","Wooferx"},
ro={},
id={"Djealvi"},
de={"Caitybumz","Heronius","Modnut"}
}

tfm.get.misc.helpers
Returns a list of helpers by community.
a dit :
tfm.get.misc.helpers={
en={"Artakha","Bloodsyn","Blossum","Doraemons","Emilyne","Haruhitastic","Herrenvolk","Johnlantern","Kazumamice","Lilmidge","Littlelogic","Maskulino","Mizzarella","Namek","Nhshrike","Postponed","Sabusha","Shamousey","Terrorted","Travelingpik","Vulli","Weemicky","Wyverna","Xxgaaraxx","Wyverna","Lemodile","Rainee","Dawnlife","Irishcow"},
br={"Behelper","Camhelper","Evehelper","Excasr","Gguuii","Imhuman","Jerrybc","Jottyhelper","Lorehelper","Marunyan","Nhahelper","Nobodyhelper","Piercehelper","Pixxye","Rufflesdqjo","Toddyhelper","Zebrahelper"},
fr={"Alexiax","Chiraille","Coeur","Collector","Fuyuzz","Helpium","Kannax","Kumi","Medecin","Mimy","Nepenthesss","Ringer","Shugotsuko","Yacii"},
tr={"Arfa","Bahanem","Dailyking","Ediz","Frankofon","Franquin","Imaate","Kediy","Lammause","Mezarbekcisi","Oryuken","Pisquvi","Sedatpeker","Xxmrsgreenxx"},
ru={"Avihelper","Benford","Biorhythm","Cepto","Cotesjenifer","Eshkinkot","Exlferq","Gazpromsham","Kefirboy","Kikys","Koteich","Orangkitten","Qwertyhelper","Sanoukiki","Scratte","Shambelbabel","Shaytrololo","Soulfli","Stellarway","Wercade"},
es={"Alexmusic","Bogkitty","Carcarmar","Gastuu","Hardboch","Hitsugayapd","Jellypizza","Joeddy","Ltanfor","Obemice","Pieroto","Puchetaaaaax","Ratacp","Reinasara"},
cn={"Doraemons","Klauszhang","Winnielau"},
vk={"Apkrigare","Dewilheart","Maskulino","Micehuana","Swordknight"},
nl={"Faranys","Fransjek","Jordynl","Lisaaxx","Vunne","Fiffile","Hohojosco"},
pl={"Coska","Deebox","Julkax","Laracerindar","Modliszka","Padida","Pockeq","Shyenne","Staszekowaty","Wisiaaa"},
hu={"Toboeszti","Vividia","Vogul"},
ro={"Bluelightz","Calinnn","Iulianbuhai","Magicalorb","Matzaplouata","Methusalah","Olillsa","Polypopu","Rainbowie"},
id={"Anriser","Arsheicha","Devinaperry","Diciganteng","Divineos","Djealvi","Nandananda","Ryanyonata","Xiaojiemei"},
de={"Hashiro"}
}

tfm.get.misc.cfmTeam
Returns a list of CheeseForMice staff by community.
a dit :
tfm.get.misc.cfmTeam={
en={"Sourdough","Baffler","Sabusha","Aguskyoko","Kazumamice","Thunderai","Xiaojiemei","Felliiii","Spinnando"},
br={"Excasr","Jaknew","Marunyan"},
fr={"Antoinemaalo"},
tr={"Lammause","Imaate"},
ru={"Stellarway","Eddiesti"},
es={"Aguskyoko","Hitsugayapd","Besito","Ltanfor"},
cn={},
vk={"Ordboka"},
nl={"Musketrat"},
pl={"Staszekowaty"},
hu={"Vividia"},
ro={"Magicalorb"},
id={"Xiaojiemei"},
de={}
}

tfm.get.misc.mapCrew
Returns a list of Map Crew members by community.
a dit :
tfm.get.misc.mapCrew={
en={"Akitauki","Bezzaaa","Colinzzd","Diegots","Ecrous","Finalnova","Impuredeath","Jetmaus","Juliiien","Nyoibou","Bolinboy","Sharpiepoops","Yoyoyorlozer"},
br={"Diegots","Roflzor"},
fr={"Aewing","Juliiien","Killerlux"},
tr={},
ru={},
es={"Jraton"},
cn={},
vk={},
nl={"Colinzzd"},
pl={},
hu={},
ro={},
id={},
de={}
}

tfm.get.misc.sentinels
Returns a list of Sentinels by community.
a dit :
tfm.get.misc.sentinels={
en={"Caitybumz","Icewolfbob","Katburger","Mausibiene","Ramenfrog","Vulli","Whiskypickle","Takumisyn","Bolinboy"},
br={"Audrian","Faustosilva","Nhokw","Plizzmaigod","Randomod","Roflzor"},
fr={"Hollya","Kittynian","Meeyo","Mlledebby","Modomaya","Modopops","Modothemis","Modozap","Nihoshi","Thiht","Violainator"},
tr={"Aylakfare","Deneyfaresi","Ediz","Nehirr","Oshesalady","Skwillex"},
ru={"Denezhki","Minamur","Soulfli","Wercade","Xabq"},
es={"Aguskyoko","Asymptotee","Levols","Modogrande","Shyraa"},
cn={"Infactimacat","Momokolee"},
vk={"Finland"},
nl={"Micaiahx"},
pl={"Coska","Milkycoffee"},
hu={},
ro={},
id={"Policemod"},
de={"Neegatron"}
}

http://i.imgur.com/4vSFf.png
tfm.enum.shamanObject Extension
Extends tfm.enum.shamanObject to support all objects.
a dit :
local shObjs = {
heavyBall=5,
smallRoughBoard=8,
largeRoughBoard=9,
redAnchor=11,
redAnchorClockwise=12,
redAnchorAnticlockwise=13,
greenAnchor=14,
greenAnchorClockwise=15,
greenAnchorAnticlockwise=16,
cannonUp=17,
cannonDown=18,
cannonRight=19,
cannonLeft=20,
yellowAnchor=22,
spirit=24,
fakeCheese=25,
bluePortal=26,
orangePortal=27,
balloonRed=29,
balloonGreen=30,
balloonYellow=31,
valentineArrow=35,
apple=39,
sheep=40,
totem=44,
transformedSmallBox=48,
transformedLargeBox=49,
transformedAnvil=50,
transformedSmallBoard=51,
transformedSmallBoard=52,
transformedMouse=53,
cloud=57,
demolition=58,
bubble=59,
tinyBoard=60,
stableRune=62,
balloonAnchor=66,
conjuration=88
}
for n,i in pairs(shObjs) do
tfm.enum.shamanObject[n] = i
end

Clothing
An organised list of all clothing with IDs, item names, cheese and fraise prices.
a dit :
clothing={
--{ID,Name,Cheese Cost,Fraise Cost}
fur={
{1,"Fur",nil,nil},
{2,"Cow Fur",6000,300},
{3,"Siamese Cat Fur",6000,300},
{4,"Rabbit Fur",6000,300},
{5,"Cow Fur v2",6000,300},
{6,"White-Brown Fur",6000,300},
{7,"Black-White Cat Fur",800,350},
{8,"Tiger Fur",10000,400},
{9,"Fox Fur",7000,400},
{10,"Skeleton Costume",nil,nil},
{11,"Black-grey Fur",7000,350},
{12,"Black-brown Fur",6500,325},
{13,"Racoon Fur",6000,300},
{14,"Snow Fur",6000,300},
{15,"Red Panda",6000,400},
{16,"Bunny Fur",nil,nil},
{17,"Zebra Fur",6000,300},
{18,"Panda Fur",6000,400},
{19,"Moon Fur",7000,400},
{20,"Sun Fur",7000,400}
},
head={
{0,"Nothing",nil,nil},
{1,"Helicopter Hat",500,nil},
{2,"Straw Hat",200,nil},
{3,"Helmet",20,nil},
{4,"Top Hat",200,nil},
{5,"Sun Hat",100,nil},
{6,"Fedora",500,nil},
{7,"Soldier Helmet",200,nil},
{8,"Miner hat",300,nil},
{9,"General's Cap",500,nil},
{10,"Beret",100,nil},
{11,"Ninja headband",500,nil},
{12,"Horns",200,nil},
{13,"Halo",500,nil},
{14,"Viking hat",300,nil},
{15,"Bandit Mask",200,nil},
{16,"Pirate Hat",300,nil},
{17,"Witch hat",200,nil},
{18,"Riding helmet",300,nil},
{19,"Nurse Cap",300,nil},
{20,"Police Cap",500,nil},
{21,"Santa Hat",200,nil},
{22,"Chef's hat",300,nil},
{23,"Bunny Ears",400,nil},
{24,"Shower Cap",50,nil},
{25,"Cow Boy hat",250,nil},
{26,"Lemon hat",300,nil},
{27,"Mandarin Hat",800,nil},
{28,"Palm hairstyle",300,nil},
{29,"Uncle Sam hat",500,nil},
{30,"Simpson hat",200,nil},
{31,"Mario hat",300,nil},
{32,"Super Sayen hat",800,nil},
{33,"Party Hat",150,nil},
{34,"Asterix Hat",400,nil},
{35,"Crown",1000,nil},
{36,"Dreadlocks",500,nil},
{37,"Afro",200,nil},
{38,"Pharaoh Hat",800,nil},
{39,"Pumpkin Head",nil,nil},
{40,"Skull Mask",nil,nil},
{41,"Antlers",nil,nil},
{42,"Snowman Head",nil,nil},
{43,"Blonde Hair",200,nil},
{44,"Campaign hat",500,nil},
{45,"Quiff Hair",nil,nil},
{46,"Coolie Hat",nil,nil},
{47,"Indian Headress",1500,nil},
{48,"Panama Hat",300,nil},
{49,"Jester Hat",500,nil},
{50,"Deadmau5 Hat",400,nil},
{51,"Pilot Hat",200,nil},
{52,"Megaman Hat",400,nil},
{53,"Viewtiful Joe Hat",nil,nil},
{54,"Eggshell",50,nil},
{55,"Cocked Hat",200,nil},
{56,"Fish Hat",300,nil},
{57,"Cat Hat",nil,nil},
{58,"Fish Bowl",nil,nil},
{59,"Bow",nil,nil},
{60,"Egg Basket",nil,nil},
{61,"Orange Hair Hat",nil,nil},
{62,"Luffy Hat",nil,nil},
{63,"Sonic Hair",350,nil},
{64,"Turkish Hat",nil,nil},
{65,"Brunette Hair",200,nil},
{66,"Link Hat",300,nil},
{67,"Shark Hat",400,nil},
{68,"Rainbow Dash's Mane",200,nil},
{69,"Twillight Sparkle's Mane",200,nil},
{70,"AppleJack's Mane",200,nil},
{71,"Pinkie Pie's Mane",200,nil},
{72,"Rarity's Mane",200,nil},
{73,"Fluttershy's Mane",200,nil},
{74,"Ushanka",nil,nil},
{75,"Coonskin Hat",nil,nil},
{76,"Paper Bag",200,nil},
{77,"Sombrero",250,nil},
{78,"Ash's Hat",300,nil},
{79,"Sleep Cap",nil,nil},
{80,"Knife In Head",nil,nil},
{81,"Ghost Sheet",nil,nil},
{82,"Bat Wings",nil,nil},
{83,"Turban",nil,nil},
{84,"Christmas Tree",nil,nil},
{85,"Stocking",nil,nil},
{86,"Krissim's Cockatrice Head",nil,nil},
{87,"Banana Leaf Headdress",nil,nil},
{88,"Straw Panache",nil,nil},
{89,"Fisherman Hat",nil,nil},
{90,"Fishing Rod",nil,nil},
{91,"Shell",nil,nil},
{92,"Captain Cap",nil,nil},
{93,"Sailor Cap",nil,nil},
{94,"Chicken",nil,nil},
{95,"Cake Hat",},
{96,"Shadow Hat",nil,nil},
{97,"Ice Hat",nil,nil},
{98,"Lion Hat",nil,nil},
{99,"Tiara",nil,nil},
{100,"Break",nil,nil},
{101,"Hokage Hat",nil,nil},
{102,"Spartan Helmet",nil,nil},
{103,"Candle Hat",nil,nil},
{104,"Ice Cube",nil,nil},
{105,"Frog Beanie",nil,nil},
{106,"Chick Hat",nil,nil},
{107,"Panda Beanie",nil,nil},
{108,"Graduate Hat",nil,nil},
{109,"Coconut Shell",nil,nil},
{110,"Underpants",nil,nil}
},
eye={
{0,"Nothing",nil,nil},
{1,"Sunglasses",200,nil},
{2,"Heartglasses",200,nil},
{3,"Evil sunglasses",nil,nil},
{4,"Monocle",200,nil},
{5,"Eyepatch",300,nil},
{6,"Tuba",nil,nil},
{7,"3D Glasses",50,nil},
{8,"Glasses",50,nil},
{9,"Make Up",nil,nil},
{10,"Shutter Glasses",100,nil},
{11,"Cyclops Glasses",200,nil},
{12,"Kitsune",nil,nil},
{13,"Nose item",nil,nil},
{14,"Carnival Mask",nil,nil},
{15,"Creeper Mask",nil,nil},
{16,"Japan expo headband",nil,nil},
{17,"Bandages",nil,nil},
{18,"Eyes Crazy",500,50}
},
mouth={
{0,"Nothing",nil,nil},
{1,"Moustache",100,nil},
{2,"Straw",25,nil},
{3,"Bowtie",150,nil},
{4,"Pipe",400,nil},
{5,"Rose",300,nil},
{6,"Green Lightsaber",300,nil},
{7,"Red Lightsaber",300,nil},
{8,"Knife",400,nil},
{9,"Gas Mask",400,nil},
{10,"Clover",20,nil},
{11,"Fish Bones",nil,nil},
{12,"Nipple",150,nil},
{13,"Lollipop",150,nil},
{14,"Surgeon Mask",50,nil},
{15,"Pumpkin Basket",nil,nil},
{16,"Red Nose",nil,nil},
{17,"Buck Teeth",2,nil},
{18,"Minecraft pick axe",400,nil},
{19,"Strawberry",nil,nil},
{20,"Paint Brush",20,2},
{21,"Ice Lolly",60,6},
{22,"Bone",100,10},
{23,"Donut",100,10},
{24,"Vampire Teeth",nil,nil},
{25,"Chocolate",nil,nil},
{26,"Gingerbread Cookie",nil,nil},
{27,"Chocolate Box",nil,nil},
{28,"Bouquet",nil,nil},
{29,"Carrot",50,5},
{30,"Turkish cake",200,40},
{31,"Bamboo",200,40},
{32,"Japanese Fan",nil,nil},
{33,"Diploma",300,40},
{34,"Sardine",nil,nil}
},
ear={
{0,"Nothing",nil,nil},
{1,"Bow",100,nil},
{2,"Spider Earring",nil,nil},
{3,"Bauble Earring",nil,nil},
{4,"Flower in Hair",20,nil},
{5,"Headphones",300,nil},
{6,"Heart Earring",nil,nil},
{7,"Poisson Earring",nil,nil},
{8,"Star Earring",nil,nil},
{9,"Cheese Earring",nil,nil},
{10,"Lenneth Helm",4001,nil},
{11,"Earmuffs",nil,nil},
{12,"Candy Cane Earring",nil,nil},
{13,"Rose Headband",nil,nil},
{14,"Anglish Bunny Headband",200,nil},
{15,"Holldine mask",nil,nil},
{16,"Fish Earring",nil,nil},
{17,"Spy glass",400,40},
{18,"Hoop Earrings",40,4},
{19,"Rin Kagamine Hairband",100,10},
{20,"Frankstein Screws",nil,nil},
{21,"Arrow in the Head",300,40},
{22,"Skull earring",nil,nil},
{23,"Frozen Ear",nil,nil},
{24,"Bunny Earring",nil,nil},
{25,"Frangipani",nil,nil}
},
neck={
{0,"Nothing",nil,nil},
{1,"Tri Coloured Scarf",200,nil},
{2,"Bandana",200,nil},
{3,"Beard",nil,nil},
{4,"Flowers",50,nil},
{5,"Tie",nil,nil},
{6,"Green and grey scarf",50,nil},
{7,"Bell necklace",nil,nil},
{8,"Barrel necklace",100,nil},
{9,"Halloween scarf",nil,nil},
{10,"Red wreath",nil,nil},
{11,"Bow tie",nil,nil},
{12,"Umbrella",nil,nil},
{13,"Camera",400,40},
{14,"Striped tie",200,40},
{15,"Medal",nil,nil}, -- Event item ?
{16,"Evil eye amulet",200,40}
},
hair={
{0,"Nothing",nil,nil},
{1,"Punk Hairstyle",400,40},
{2,"Windswept Hairstyle",400,40},
{3,"Normal Male Hair",400,40},
{4,"Fringe",400,40},
{5,"Chanel",400,40},
{6,"Applebloom's Mane",300,nil},
{7,"Scootaloox's Mane",300,nil},
{8,"Sweetiebell's Mane", 300,nil},
{9,"Hatsune Miku's Hairstyle",400,40},
{10,"Rin Kagamine's Hairstyle",200,40},
{13,"Golden Curls",400,40},
{14,"Forelock",nil,nil}
},
tail={
{1, "Diamond tail",2000,200},
{2, "Star tail",nil,nil},
{3, "Bow tail",1000,100},
{4, "Heart tail",nil,nil},
{5, "Easter egg tail",nil,nil},
{6, "Sun tail",1500,150},
{7, "Moon tail",1500,150}
}
}

loop
Faster loop than eventLoop by using timers. Returns timer IDs if you need to stop them.
a dit :
function loop(fnc, ticks)
local s = 1000/ticks
local timers = {}
for t = 0, 1000 - s, s do
system.newTimer(function () table.insert(timers, system.newTimer(fnc, 1000, true)) end, 1000 + t, false)
end
return timers
end

trans
Handles translating to different languages, falling back to English if translations for a certain community isn't there.
a dit :
translations={
EN={
welcome="Hi."
},
BR={
welcome="Oi."
}
}

function trans(mes)
if translations[tfm.get.room.community] and translations[tfm.get.room.community][mes] then
return translations[tfm.get.room.community][mes]
else
return translations.EN[mes]
end
end

 

Dernière modification le 1429913640000
Shamousey
« Consul »
1381174140000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#3
  0
Reserved post for future functions *-*

Remember that the lists of members in specific groups (mods/admins/etc.) and clothing won't always be up to date, although I'll try to update it as soon as any changes are needed.
Enginfener
« Citoyen »
1381266300000
    • Enginfener#0000
    • Profil
    • Derniers messages
    • Tribu
#4
  0
So, look : 1;0,0,0,0,0,0,0,0,0 we add
Mikuhl
« Citoyen »
1381267440000
    • Mikuhl#3311
    • Profil
    • Derniers messages
    • Tribu
#5
  0
Shamousey a dit :
Reserved post for future functions *-*

Remember that the lists of members in specific groups (mods/admins/etc.) and clothing won't always be up to date

We need a these to actually be real, then it would make for some cute welcome messages, like I heared rumored that cfmbot used to say, "Your [randomized shop item you are wearing] looks stunning!"
Ethanrockz
« Citoyen »
1381946340000
    • Ethanrockz#0000
    • Profil
    • Derniers messages
    • Tribu
#6
  0
translations={
EN={
welcome="Hi."
},
BR={
welcome="Oi."
}
}

function trans(mes)
if translations[tfm.get.room.community] and translations[tfm.get.room.community][mes] then
return translations[tfm.get.room.community][mes]
else
return translations.EN[mes]
end
end

This dosnt work for me ;-;
Shamousey
« Consul »
1381949280000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#7
  0
Ethanrockz a dit :
This dosnt work for me ;-;

This works fine. What exactly are you trying to use it?
Ethanrockz
« Citoyen »
1381949640000
    • Ethanrockz#0000
    • Profil
    • Derniers messages
    • Tribu
#8
  0
I just went on br server and got my friends to say hi/Hi/Hi. but nothing happened
(I did the Oi thing aswell)
Shamousey
« Consul »
1381949940000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#9
  0
Ethanrockz a dit :
I just went on br server and got my friends to say hi/Hi/Hi. but nothing happened
(I did the Oi thing aswell)

Getting people to say "hi" does nothing, this works when you need to print/display text in different languages.

print(trans("welcome")) will display "Hi." on any server but "Oi." on the BR one.
Ethanrockz
« Citoyen »
1381949940000
    • Ethanrockz#0000
    • Profil
    • Derniers messages
    • Tribu
#10
  0
Shamousey a dit :
Getting people to say "hi" does nothing, this works when you need to print/display text in different languages.

print(trans("welcome")) will display "Hi." on any server but "Oi." on the BR one.

Thanks for helping me c:
Theleetcoder
« Citoyen »
1382972160000
    • Theleetcoder#0000
    • Profil
    • Derniers messages
    • Tribu
#11
  0
U' can add :
tfm.exec.chatMessage

a dit :

settings = { isDebug = false } -- true for tribe house, false for normals room.

local chatMessage = tfm.exec.chatMessage
function tfm.exec.chatMessage(message, name)
if settings.isDebug then
print(message)
else
chatMessage(message, name)
end
end

 
Safwanrockz
« Censeur »
1382982000000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#12
  0
Theleetcoder a dit :
U' can add :
tfm.exec.chatMessage

But does it show to all the players?
Shamousey
« Consul »
1382983140000
    • Shamousey#0095
    • Profil
    • Derniers messages
    • Tribu
#13
  0
Safwanrockz a dit :
But does it show to all the players?

No, but it'd make transitioning from a tribehouse script to a public module much easier.
Jeremiahmice
« Citoyen »
1383111120000
    • Jeremiahmice#0000
    • Profil
    • Derniers messages
    • Tribu
#14
  0
i dont get it... someone help me!
Fluffyshine
« Citoyen »
1384002660000
    • Fluffyshine#0000
    • Profil
    • Derniers messages
    • Tribu
#15
  0
nice one
Thewildnes
« Citoyen »
1384008660000
    • Thewildnes#0000
    • Profil
    • Derniers messages
    • Tribu
#16
  0
Good thread
Abdeltif
« Citoyen »
1387993980000
    • Abdeltif#0000
    • Profil
    • Derniers messages
    • Tribu
#17
  0
the loop function won't work for us, :(
Safwanrockz
« Censeur »
1387997520000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#18
  0
Abdeltif a dit :
the loop function won't work for us, :(

Yep, because it uses the system.newTimer function.

Also, this function might be useful though.
table.delete a dit :

function table.delete(t,v)
for key,value in ipairs(t) do
if v == t[key] then
table.remove(t, key)
end
end
end

Deletes a value from a specific table.
Woebegone
« Citoyen »
1387997520000
    • Woebegone#8377
    • Profil
    • Derniers messages
    • Tribu
#19
  0
How can you load a map onto the lua code?
Safwanrockz
« Censeur »
1387997640000
    • Safwanrockz#0095
    • Profil
    • Derniers messages
    • Tribu
#20
  0
Juliantwofan a dit :
How can you load a map onto the lua code?

tfm.exec.newGame(@MapCode).
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Function Library
1 / 3 › »
© Atelier801 2018

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

Version 1.27