×

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
  • /
  • Script Requests
« ‹ 143 / 160 › »
Script Requests
Overjoy06
« Citoyen »
1523341320000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2841
  0
how do you add a physical object type = water but you can swim on it


sorry for bad grammar
Olo
« Citoyen »
1523346360000
    • Olo#5624
    • Profil
    • Derniers messages
#2842
  0
I need a script that when a player died on chat #lua it will say (player) just died!
Onkei
« Citoyen »
1523347080000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#2843
  1
Overjoy06 a dit :
how do you add a physical object type = water but you can swim on it


sorry for bad grammar

Unfortunately, you can't create a water ground that's swimmable in lua (I think?). Here's an example of a water ground being created w lua though:


Code Lua

1
2
3
4
5
6
7
8
9
tfm.exec.addPhysicObject(0, 200, 200, {
type = 9,
width = 100,
height = 100,
friction = 0.2,
restitution = 0.3,
miceCollision = true,
groundCollision = true
})


Simon665 a dit :
I need a script that when a player died on chat #lua it will say (player) just died!


Code Lua

1
2
3
function eventPlayerDied(name)
print(name .. " just died!")
end
Overjoy06
« Citoyen »
1523347140000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2844
  0
yeah i tried too.
Shianinja
« Citoyen »
1523366340000
    • Shianinja#2005
    • Profil
    • Derniers messages
    • Tribu
#2845
  0
Onkei a dit :
Overjoy06 a dit :
Is it possible that the random person that got teleported example code :
The random person who got teleported can only see some textareas
And yes, this is a new account

The ui.addTextArea method has an argument that you can specify which player can see the textArea. If a name is given, only that player can see the textArea, nil if you want everyone to see it.

In this case, randomPlayer is feeded into the method as the argument, so only the randomly selected player can see the textArea.


Code Lua

1
2
3
4
5
6
7
8
9
10
players = {}

for name, data in next, tfm.get.room.playerList do
table.insert(players, name)
end

randomPlayer = players[math.random(1, #players)]

tfm.exec.movePlayer(randomPlayer, 400, 200, false, 0, 50, false)
ui.addTextArea(0, "Only the randomly selected player can see this.", randomPlayer, 20, 20, nil, 30, 0x324650, 0x212F36, 0.8, false)

leaving 5 seconds of the map and gaining space and play for the live mouse

Dernière modification le 1523402880000
Overjoy06
« Citoyen »
1523415540000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2846
  0
there's a textarea saying cannon turret now if you click it. It will spawn a cannon Coords = X : 1500 Y : 200
It will spawn a cannon on a loop.

Dernière modification le 1523417940000
Alsalam_alaikum
« Citoyen »
1523479140000
    • Alsalam_alaikum#5209
    • Profil
    • Derniers messages
#2847
  0
Bolodefchoco a dit :
Fuzzyfirsdog a dit :
Example of a !p [username] function?

Code Lua

1
2
3
4
5
6
eventChatCommand = function(n, c)
local name = c:match("^p +([A-Za-z0-9_%+]+#%d%d%d%d)")
if name and tfm.get.room.playerList[name] then
-- do whatever you want
end
end

Thanks again for this because I actually understand the match function. I used it for this too in a part of my module :

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function eventPopupAnswer(popupID, n, answer)
local ans = answer:match("<a href='event:light'>")
local tp = answer:match("<a href='event:tpers'>")
local safe = answer:match("<a href='event:safety'>")

if not ans and not tp and not safe then
data[n].description=answer
ui.addTextArea(144, "<font size='15'><font face='Calibri'>Wins : "..data[n].wins.."\n\nMessage Lights : "..data[n].lights.."\n\nTeleporters : "..data[n].tps.."\n", n, 275, 82, 250, 300, 0x000000, 0x00ff64, 1, true)
ui.addTextArea(155, "<p align='center'><font size='17'><font face='calibri'>"..n, n, 277, 33, 245, 29, 0x1d75a1, 0x00ff64, 1, true)
ui.addTextArea(166, "<V>Title<N> : «"..data[n].title.."»\n", n, 285, 268, 227, 100, 0x324650, 0x000000, 1, true)
ui.addTextArea(177, "<V>Description [<J><a href='event:descr'>change</a><V>]<N> : <font size='10'>"..data[n].description, n, 419, 92, 90, 160, 0x324650, 0x000000, 1, true)
ui.addTextArea(55, "<p align='center'><font size='18'><font face='Calibri'><a href='event:close'><VP><b>CLOSE", n, 410, 336, 100, 30, 0x000000, 0x00ff6f, 1, true)


end
end
Sebafrancuz
« Consul »
1523537460000
    • Sebafrancuz#0000
    • Profil
    • Derniers messages
    • Tribu
#2848
  0
Fuzzyfirsdog a dit :
Bolodefchoco a dit :
Fuzzyfirsdog a dit :
Example of a !p [username] function?

Code Lua

1
2
3
4
5
6
eventChatCommand = function(n, c)
local name = c:match("^p +([A-Za-z0-9_%+]+#%d%d%d%d)")
if name and tfm.get.room.playerList[name] then
-- do whatever you want
end
end

Thanks again for this because I actually understand the match function. I used it for this too in a part of my module :

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function eventPopupAnswer(popupID, n, answer)
local ans = answer:match("<a href='event:light'>")
local tp = answer:match("<a href='event:tpers'>")
local safe = answer:match("<a href='event:safety'>")

if not ans and not tp and not safe then
data[n].description=answer
ui.addTextArea(144, "<font size='15'><font face='Calibri'>Wins : "..data[n].wins.."\n\nMessage Lights : "..data[n].lights.."\n\nTeleporters : "..data[n].tps.."\n", n, 275, 82, 250, 300, 0x000000, 0x00ff64, 1, true)
ui.addTextArea(155, "<p align='center'><font size='17'><font face='calibri'>"..n, n, 277, 33, 245, 29, 0x1d75a1, 0x00ff64, 1, true)
ui.addTextArea(166, "<V>Title<N> : «"..data[n].title.."»\n", n, 285, 268, 227, 100, 0x324650, 0x000000, 1, true)
ui.addTextArea(177, "<V>Description [<J><a href='event:descr'>change</a><V>]<N> : <font size='10'>"..data[n].description, n, 419, 92, 90, 160, 0x324650, 0x000000, 1, true)
ui.addTextArea(55, "<p align='center'><font size='18'><font face='Calibri'><a href='event:close'><VP><b>CLOSE", n, 410, 336, 100, 30, 0x000000, 0x00ff6f, 1, true)


end
end

It's better to use string.find in that case

Dernière modification le 1523537520000
Borntolol
« Citoyen »
1525117680000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2849
  0
How would i make an event only execute to the player that has the most points
Bolodefchoco
« Sénateur »
1525117920000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2850
  0
Borntolol a dit :
How would i make an event only execute to the player that has the most points

That depends. Would that be a "fast" loop or just once?

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function event(player, score)
-- Do whatever you want
end

function highscore()
local players = {}
for k, v in next, tfm.get.room.playerList do
player[#players + 1] = { k, v.score }
end
table.sort(player, function(a, b) return a[2] > b[2] end)
return table.unpack(players[1])
end

-- Event with the player that has the highest score
event(highscore())
Borntolol
« Citoyen »
1525118460000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2851
  0
itll loop every time a new game round starts ( not map )
Borntolol
« Citoyen »
1525118820000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2852
  0
Like um, lets say i wanted to make the highest scoring player a vampire or sham, how would i execute that because im pretty sure tfm.exec.setShaman() wont work
Bolodefchoco
« Sénateur »
1525122600000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2853
  0
Borntolol a dit :
Like um, lets say i wanted to make the highest scoring player a vampire or sham, how would i execute that because im pretty sure tfm.exec.setShaman() wont work

Code Lua

1
2
3
4
5
6
7
8
9
10
function highscore()
local players = {}
for k, v in next, tfm.get.room.playerList do
player[#players + 1] = { k, v.score }
end
table.sort(player, function(a, b) return a[2] > b[2] end)
return players[1]
end

tfm.exec.setShaman(highscore())

Dernière modification le 1525122660000
Borntolol
« Citoyen »
1525157820000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2854
  0
launcher = {Borntolol = true}
i need a command that will make the launcher the sham, vamp or whatever i want it to be without writing tfm.exec.setShaman("Borntolol)
do i just put launcher in there without the ""
Honorabilis
« Consul »
1525174380000
    • Honorabilis#0000
    • Profil
    • Derniers messages
    • Tribu
#2855
  0
Borntolol a dit :
launcher = {Borntolol = true}
i need a command that will make the launcher the sham, vamp or whatever i want it to be without writing tfm.exec.setShaman("Borntolol)
do i just put launcher in there without the ""

If you have an idea how to do, just try it and see the result. If it does not work try another idea. This is how can you learn the language. If you can not find any solution, ask; but try it yourself first.
Massi
« Consul »
1525174920000
    • Massi#0095
    • Profil
    • Derniers messages
    • Tribu
#2856
  0
Borntolol a dit :
launcher = {Borntolol = true}
i need a command that will make the launcher the sham, vamp or whatever i want it to be without writing tfm.exec.setShaman("Borntolol)
do i just put launcher in there without the ""

The commands are :
!sham - makes the launcher the shaman
!vamp - makes the launcher the vampire
Code Lua

1
2
3
4
5
6
7
8
9
10
11
Launcher={["Borntolol#0000"]=true}

function eventChatCommand(n, cmd)
if Launcher[n] then
if cmd == "sham" then
tfm.exec.setShaman(n)
elseif cmd == "vamp" then
tfm.exec.setVampirePlayer(n)
end
end
end

Dernière modification le 1525175040000
Borntolol
« Citoyen »
1525189080000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2857
  0
im dumb because i already knew how to do that, i just confused myself lol
Borntolol
« Citoyen »
1525190400000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2858
  0
This won't work and i dont see why, ill put a small snippet of the part that doesnt work.
Code Lua

1
2
3
4
5
Launcher={["Borntolol#0000"]=true}
if Launcher[n] then -- These commands under bascially wont do anything because im not sure what happened *-*
tfm.exec.setShaman(n)
tfm.exec.movePlayer("///",400,75,false,0,0,false) -- Where the /// is I dont know how to set it to just the launcher
end
Bolodefchoco
« Sénateur »
1525192140000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2859
  1
Borntolol a dit :
im dumb because i already knew how to do that, i just confused myself lol

That happens. This is how we start ^_^


Borntolol a dit :
This won't work and i dont see why, ill put a small snippet of the part that doesnt work.
Code Lua

1
2
3
4
5
Launcher={["Borntolol#0000"]=true}
if Launcher[n] then -- These commands under bascially wont do anything because im not sure what happened *-*
tfm.exec.setShaman(n)
tfm.exec.movePlayer("///",400,75,false,0,0,false) -- Where the /// is I dont know how to set it to just the launcher
end

There are some things you can do.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- If the launcher has more than 1 user, then it's better to set then values, not indexes:
Launcher = {"Borntolol#0000", "Bolodefchoco#0000"}

-- I suggest you to put the code below in a function, otherwise it won't execute more than once
for _, name in next, Launcher do -- BUT, if you choose indexes, replace "_, name" to "name"
tfm.exec.setShaman(name)
tfm.exec.movePlayer(name, 400, 75, false, 0, 0, false)
end
-------------------------------------------------------------------------------
-- Or, if it's like in a chat command:

Launcher = {"Borntolol#0000", "Bolodefchoco#0000"}

local isLauncher = false
for _, name in next, Launcher do
if name == n then
isLauncher = true
break
end
end


-- If you use Launcher with indexes instead of values, then you can use
-- isLauncher = not not Launcher[n] -- Checks if Launcher[n] exists and returns a boolean (not not)

if isLauncher then
tfm.exec.setShaman(n)
tfm.exec.movePlayer(n, 400, 75, false, 0, 0, false)
end

Now, if it's only you, you may use:
Code Lua

1
2
3
4
5
6
7
8
9
10
-- For the user that launches the script
do
local _, nickname = pcall(nil)
tfm.get.luaScriptLoader = string.match(nickname, "(.-)%.")
end

if n == tfm.get.LuaScriptLoader then
tfm.exec.setShaman(n)
tfm.exec.movePlayer(n, 400, 75, false, 0, 0, false)
end

Anyways, your code is not wrong. The problem is that you didn't put the chunk in an event, so, as I said, it's only executed once.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
Launcher={["Borntolol#0000"]=true}

-- !command
eventChatCommand = function(n, cmd)
if cmd == "command" then
if Launcher[n] then
tfm.exec.setShaman(n)
tfm.exec.movePlayer(n,400,75,false,0,0,false)
end
end
end
Massi
« Consul »
1525196040000
    • Massi#0095
    • Profil
    • Derniers messages
    • Tribu
#2860
  1
The lord has answered above :3 ↑
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Script Requests
« ‹ 143 / 160 › »
© Atelier801 2018

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

Version 1.27