×

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
« ‹ 157 / 160 › »
Script Requests
Phuphle
« Citoyen »
1586535180000
    • Phuphle#0000
    • Profil
    • Derniers messages
#3121
  0
Hey all.

Is it possible to utilise a chat command such as /npp in a tfm lua script? I'm trying to make a module where there is a queue of the next maps to be played and every player can have one map in that queue at a time. If /npp can't be used how can I detect when a round has ended (all mice have died or the timer is 0) efficiently? Do i have to constantly use event loop?

Thanks,
Phuphle.
Aen_elle
« Citoyen »
1587072900000
    • Aen_elle#0000
    • Profil
    • Derniers messages
    • Tribu
#3122
  0
Hi,
I carefully looked at the documentation, but could not find :c
Any way to give mice rolling? Like skill "Rollout" in Physicist?
Thanks
Bolodefchoco
« Sénateur »
1587074940000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#3123
  1
Liberrate a dit :
Thanks anyway, Hypermousem. You helped me a lot!

Edit:
I have another question :D Is it possible to make object which will be "clickable" on map?. I mean that object will "shine" when we hover mouse over it, and after clicking lua perform some actions? I know that I can check specific coordinates for clicking, but is there way to inform user that something is clickable, by visualizing it?

You can't make it shine, but you can use invisible textareas above something.

I recommend you my undocumented callback class.

To make it trigger callbacks, you have to add this to your code:
Code Lua

1
2
3
4
5
6
eventTextAreaCallback = function(id, playerName, eventName)
if string.find(eventName, "callback.", 1, true) then
local data = tfm.get.room.playerList[playerName]
callback.__get(string.sub(eventName, 10)):performAction(playerName, data.x, data.y)
end
end

To create them, you use
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
-- (str) Name of the object, (int) X position, (int) Y position, (int) Width, (int) Height, (bool) Whether it starts invisible or visible (default = visible = false)
local bbbb = callback.new("banana", 100, 200, 50, 50, false)

-- If you choose it to be invisible ^ (true), to make it appear you'd use
bbbb:textarea("Bolodefchoco#0000") -- displays the callback to me
bbbb:display(function(playerName, playerData) -- displays to everyone that this function returns true
return not playerData.isDead
end)

-- To make it (un)/fixed in the screen
bbbb:setFixed(true)

-- To make it clickable, with an optional border range
bbbb:setClickable(5) -- 5px of border

-- To set a callback when clicked
bbbb:setAction(function(playerName, x, y)
print(playerName .. " has clicked")
end)

-- (eventTextAreaCallback already does that) To trigger the callback when clicked
bbbb:performAction(playerName, x, y) -- it checks whether it is in the clickable area first

-- Deletes callback to a player
bbbb:remove("Bolodefchoco#0000")

--- Deletes to everyone
bbbb:remove()

Phuphle a dit :
Hey all.

Is it possible to utilise a chat command such as /npp in a tfm lua script? I'm trying to make a module where there is a queue of the next maps to be played and every player can have one map in that queue at a time. If /npp can't be used how can I detect when a round has ended (all mice have died or the timer is 0) efficiently? Do i have to constantly use event loop?

Thanks,
Phuphle.

1 - You can't
2 - Yes, you need to rely on eventLoop

For performance in checking alive players, I recommend you this thread.

Code Lua

1
2
3
4
5
eventLoop = function(elapsedTime, remainingTime)
if remainingTime < 500 and players.alive._count < 1 then
-- Next map
end
end

Aen_elle a dit :
Hi,
I carefully looked at the documentation, but could not find :c
Any way to give mice rolling? Like skill "Rollout" in Physicist?
Thanks

No :(

Dernière modification le 1587075840000
Burak
« Citoyen »
1587337680000
    • Burak#5215
    • Profil
    • Derniers messages
    • Tribu
#3124
  0
if the player is at the 3rd checkpoint and leaves the room, player resumes when player comes back
what is this code
Authory
« Citoyen »
1587396360000
    • Authory#0000
    • Profil
    • Derniers messages
    • Tribu
#3125
  0
Can we create a title menu for lua?
Perfecteca
« Sénateur »
1588542180000
    • Perfecteca#0000
    • Profil
    • Derniers messages
    • Tribu
#3126
  0
nvm   

Dernière modification le 1590068340000
Yteiz
« Citoyen »
1588637700000
    • Yteiz#0000
    • Profil
    • Derniers messages
    • Tribu
#3127
  0
I wanted to request a script
that put two xml together
thank you
Boxofkrain
« Censeur »
1589292900000
    • Boxofkrain#0000
    • Profil
    • Derniers messages
    • Tribu
#3128
  0
Yteiz a dit :
I wanted to request a script
that put two xml together
thank you

Code Lua

1
2
3
xml1 = ''
xml2 = ''
xml3 = xml1..xml2
Mouseexyx
« Citoyen »
1591645140000
    • Mouseexyx#0000
    • Profil
    • Derniers messages
    • Tribu
#3129
  0
is it possible for a script to kill a mouse everytime the mouse pressed the down arrow key?
Boxofkrain
« Censeur »
1591647900000
    • Boxofkrain#0000
    • Profil
    • Derniers messages
    • Tribu
#3130
  0
Mouseexyx a dit :
is it possible for a script to kill a mouse everytime the mouse pressed the down arrow key?

1
2
3
4
5
6
7
8
9
10
11
function eventKeyboard(n)
tfm.exec.killPlayer(n)
end

function eventNewPlayer(n)
system.bindKeyboard(n, 3, false)
end

for n in next, tfm.get.room.playerList do
eventNewPlayer(n)
end

Dernière modification le 1591683120000
Bolodefchoco
« Sénateur »
1591651620000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#3131
  1
if it's just the down arrow key in the script then you can use eventKeyboard = tfm.exec.killPlayer
Ragnarx
« Citoyen »
1592342100000
    • Ragnarx#6155
    • Profil
    • Derniers messages
#3132
  0
......

Dernière modification le 1592481360000
Lala
« Citoyen »
1593376860000
    • Lala#0095
    • Profil
    • Derniers messages
    • Tribu
#3133
  0
Hello, I'm looking for a lua script that has vanilla maps where we race in teams without a shaman. I have a script like that but it's an old version, I'm looking for a version that includes more vanilla maps, and if possibly newer ones as well. Thanks!
Boxofkrain
« Censeur »
1593851040000
    • Boxofkrain#0000
    • Profil
    • Derniers messages
    • Tribu
#3134
  0
Lalajb a dit :
Hello, I'm looking for a lua script that has vanilla maps where we race in teams without a shaman. I have a script like that but it's an old version, I'm looking for a version that includes more vanilla maps, and if possibly newer ones as well. Thanks!

Just add them manually?
Osmanyksk123
« Consul »
1593889860000
    • Osmanyksk123#5925
    • Profil
    • Derniers messages
#3135
  0
how to be invisible when !mod writes
Lala
« Citoyen »
1594247820000
    • Lala#0095
    • Profil
    • Derniers messages
    • Tribu
#3136
  0
Boxofkrain a dit :
Lalajb a dit :
Hello, I'm looking for a lua script that has vanilla maps where we race in teams without a shaman. I have a script like that but it's an old version, I'm looking for a version that includes more vanilla maps, and if possibly newer ones as well. Thanks!

Just add them manually?

I wasn't aware I could do that, thanks!
Admiire_me
« Citoyen »
1594471380000
    • Admiire_me#6770
    • Profil
    • Derniers messages
#3137
  0
hey, i've this football script (special thanks to codes of makinit, eliaseeg, thewav, bolodefchoco, tat#0095 and shamousey)
Here
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
local map = '<C><P F="0" L="1400" /><Z><S><S L="26" X="13" H="104" Y="328" T="9" P="0,0,,,,0,0,0" /><S L="26" H="104" X="1387" Y="327" T="9" P="0,0,,,,0,0,0" /><S P="0,0,0,0.3.2,0,0,0,0" L="1400" X="700" Y="389" T="6" H="21" /></S><D /><O /></Z></C>'
local taked = false
local mice = {}
local ball
local haveTheBall
local red = {id = 1, score = 0, col = "0xFF0000", col2 = "0xFF8888", tag = "<BV>", name = "Blue Team", players = {}};
local blue = {id = 2, score = 0, col = "0x0000ff", col2 = "0x8888ff", tag = "<R>", name = "Red Team", players = {}};
local players = {}
local playerList = {}

function particles(id, x, y)
for i=1,3 do
tfm.exec.displayParticle(id, x, y, math.random(-3,3), -9, 0,math.random(8,15)/10, nil)
end
end

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

function eventNewPlayer(name)
table.insert(playerList, name)
tfm.exec.respawnPlayer(name)
mice[name] = {
haveBall = false,
facingLeft = false -- Izquierda
}
for i=1,100 do
tfm.exec.bindKeyboard(name, i, true, true)
end
end

function main()
tfm.exec.disableAutoShaman(true)
tfm.exec.disableAutoNewGame(true)
tfm.exec.disableAutoTimeLeft(true)
math.randomseed(os.time())
for n,p in pairs(tfm.get.room.playerList) do
eventNewPlayer(n)
end
tfm.exec.newGame(map)
ball = tfm.exec.addShamanObject(17, 700, 200, 0, 0, 0, true)
end

function makeTeams()
table.insert(playerList,name)
for i=1,#playerList,1 do
local index=math.random(#playerList)
local name=playerList[index]
if i%2==0 then
table.insert(red.players,name)
tfm.exec.setNameColor(name, 0xFF0000)
tfm.exec.movePlayer(name, 1274, 365)
else
table.insert(blue.players,name)
tfm.exec.setNameColor(name, 0x0000FF)
tfm.exec.movePlayer(name, 126, 365)
end
table.remove(playerList,index)
end
end
function eventNewGame()
main()
if blue.score == 10 or red.score == 10 then
main()
makeTeams()
end
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>Nadie</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
end
function eventKeyboard(name, key, down, mouseX, mouseY)
if (key == 37 or k == 65) then
mice[name].facingLeft = true
elseif (key == 39 or k == 2 or k == 68) then
mice[name].facingLeft = false
end
if key == 32 then
if not taked then
if tfm.get.room.objectList[ball] then
if pythag(mouseX, mouseY, tfm.get.room.objectList[ball].x, tfm.get.room.objectList[ball].y, 40) and not mice[name].haveBall then
particles(3, mouseX, mouseY)
tfm.exec.removeObject(ball)
haveTheBall = name
tfm.exec.giveCheese(haveTheBall)
mice[name].haveBall = true
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>"..haveTheBall.."</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
taked = true
end
end
else
if name ~= haveTheBall then
if pythag(mouseX, mouseY, tfm.get.room.playerList[haveTheBall].x, tfm.get.room.playerList[haveTheBall].y, 20) then
tfm.exec.killPlayer(haveTheBall)
tfm.exec.respawnPlayer(haveTheBall)
tfm.exec.movePlayer(haveTheBall, mouseX, mouseY)
mice[haveTheBall].haveBall = false
taked = true
mice[name].haveBall = true
haveTheBall = name
particles(3, mouseX, mouseY)
end
else
if mice[haveTheBall].facingLeft == true then
ball = tfm.exec.addShamanObject(17, mouseX-48, mouseY, -10, -10, 0, true)
mice[haveTheBall].haveBall = false
particles(3, mouseX, mouseY)
taked = false
tfm.exec.killPlayer(name)
tfm.exec.respawnPlayer(name)
tfm.exec.movePlayer(name, mouseX, mouseY)
haveTheBall = nil
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>Nadie</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
else
ball = tfm.exec.addShamanObject(17, mouseX+48, mouseY, 10, 10, 0, true)
mice[haveTheBall].haveBall = false
particles(3, mouseX, mouseY)
taked = false
haveTheBall = nil
tfm.exec.killPlayer(name)
tfm.exec.respawnPlayer(name)
tfm.exec.movePlayer(name, mouseX, mouseY)
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>Nadie</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
end
end
end
end
end

function eventPlayerDied(name)
tfm.exec.respawnPlayer(name)
for name,player in pairs(blue.players) do
tfm.exec.setNameColor(name, 0x0000FF)
end
for name,player in pairs(red.players) do
tfm.exec.setNameColor(name, 0xFF0000)
end
end
function eventLoop()
if tfm.get.room.objectList[ball] then
if (tfm.get.room.objectList[ball].x >= 1 and tfm.get.room.objectList[ball].x <= 28) and (tfm.get.room.objectList[ball].y >= 269 and tfm.get.room.objectList[ball].y <= 387) then
red.score = red.score + 1
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>Nadie</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
main()
end
if (tfm.get.room.objectList[ball].x >= 1369 and tfm.get.room.objectList[ball].x <= 1398) and (tfm.get.room.objectList[ball].y >= 275 and tfm.get.room.objectList[ball].y <= 383) then
blue.score = blue.score + 1
tfm.exec.setUIMapName("<B>#football</B> <BL>|</BL> <B><V>Nadie</V></B><N> tiene la pelota! <BL>|</BL> <BV>"..blue.score.." <N>- <R>"..red.score.."")
main()
end
end
end
main()
makeTeams()

but sometimes doesn't work goal system because eventLoop it's every 0.5s :(
who can help me?
Jaker
« Citoyen »
1598724360000
    • Jaker#9310
    • Profil
    • Derniers messages
    • Tribu
#3138
  0
Osmanyksk123 a dit :
how to be invisible when !mod writes

Code Lua

1
2
3
4
5
6
7
8
9
10
11
moderators = {["Osmanyksk123#5925"]=true,["Mod2#0000"]=true,["Mod3#0000"]=true}

function eventChatCommand(player, cmd)
if moderators[player] then
if cmd == "mod" then
tfm.exec.killPlayer(player)
end
end
end

system.disableChatCommand("mod", true)--add that if you want the command !mod to be invisible

Dernière modification le 1598812560000
Government
« Citoyen »
1601277300000
    • Government#0962
    • Profil
    • Derniers messages
#3139
  0
Searching for a giveaway lua script .
Jaker
« Citoyen »
1601489940000
    • Jaker#9310
    • Profil
    • Derniers messages
    • Tribu
#3140
  0
Government a dit :
Searching for a giveaway lua script .

Hey, i'm still new to lua but here you go

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local giveaway = {}--will store the ones who wants to participate
local total_players = 0--will store the number of players
local players = {}
local submissions = 0--clicks
local skipped = 0--will store the ones who skip

for k in next, tfm.get.room.playerList do
total_players=total_players+1--We count ppl
end

ui.addTextArea(1, "<a href='event:enter'>Enter giveaway</a>\n\n<a href='event:skip'>Skip</a>", player)

function didEveryoneEnter()
if #giveaway + skipped == total_players then--if the number of players = number of people who participated in the giveaway or skipped
local winner = giveaway[math.random(#giveaway)]--then pick a random one from those who participated
if winner then--if the winner isn't nil then add a text area with the winner's name (below)
ui.addTextArea(2, "<T>The winner is</T> <J>"..winner.."</J>", player, 300, 200, width, height, backgroundColor, borderColor, backgroundAlpha, fixedPos)
else ui.addTextArea(2, "<T>There is</T> <R>no winner ! :(</R>", player, 300, 200, width, height, backgroundColor, borderColor, backgroundAlpha, fixedPos)--else (if winner = nil, so if everyone skipped), add a text area with no winner name
end
end
end

function checksub()
if submissions == total_players then
for name,number in next, players do
if number == 1 then
giveaway[#giveaway+1]=name
didEveryoneEnter()
end
end
end
end


function eventTextAreaCallback(id, name, event)
if event == "enter" then
if not players[name] then
submissions = submissions+1
players[name] = 1
ui.updateTextArea(1, "<G>Enter giveaway</G>\n\n<G>Skip</G>", player)
end
elseif event == "skip" then
if not players[name] then
submissions = submissions+1
players[name]=2
ui.updateTextArea(1, "<G>Enter giveaway</G>\n\n<G>Skip</G>", player)
end
end
checksub()
end

Thanks noob Athesdrake#0000 for helping me fixing it.

Dernière modification le 1602175860000
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Script Requests
« ‹ 157 / 160 › »
© Atelier801 2018

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

Version 1.27