×

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
« ‹ 147 / 160 › »
Script Requests
Bolodefchoco
« Sénateur »
1532378040000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2921
  0
Syrius a dit :
How to make multiple arguments after command?

You need to split the string using a pattern.

The most commom pattern are the spaces, each white space is an argument.

To do so:

Code Lua

1
2
3
4
5
6
7
8
9
10
eventChatCommand = function(name, cmd)
local c = { }
string.gsub(cmd, "%S+", function(arg)
c[#c + 1] = arg
end)

if c[1] == "say" then -- !say hiii
print(c[2])
end
end

Dernière modification le 1532378100000
Quys
« Citoyen »
1532421360000
    • Quys#1761
    • Profil
    • Derniers messages
    • Tribu
#2922
  0
......

Dernière modification le 1532616420000
Septzko
« Citoyen »
1532421480000
    • Septzko#5248
    • Profil
    • Derniers messages
    • Tribu
#2923
  0
How can you disable the "Mort" Command
And also how can you make a TextArea?
Overjoy06
« Citoyen »
1532421660000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2924
  0
Desangres a dit :
How can you disable the "Mort" Command

tfm.exec.disableMortCommand(true)
Desangres a dit :
And also how can you make a TextArea?

ui.addTextArea(1,"Example text to display.",nil,350,180,100,40,0x324650,0x212F36,0.8,true)
Overjoy06
« Citoyen »
1532602380000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2925
  0
Anhtuan123 a dit :
How can i make a textarea that says "Equip" then when you clicked it the textarea will be removed and get replaced its more like updating it.

Code Lua

1
2
3
4
5
6
7
8
9
10
local equipped = false
ui.addTextArea(1,"<a href='event:equip'>Equip</a>",nil,400,200,100,40,0x324650,0x212F36,0.8,true)


function eventTextAreaCallback(id,n,call)
if call=="equip" then
equipped = true
ui.updateTextArea(1,"Using",nil)
end
end
Quys
« Citoyen »
1532676720000
    • Quys#1761
    • Profil
    • Derniers messages
    • Tribu
#2926
  0
hello how to make a code that when you click it
it will make a countdown then loads a map, when you load the map you can shoot a item by clicking s or down arrow
Syrius
« Consul »
1532862780000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2927
  0
Script for game of catch.

If catcher overlaps about 50% of the other player, then make the other player catcher, and remove first player as catcher.
Campwolf
« Citoyen »
1533348600000
    • Campwolf#8695
    • Profil
    • Derniers messages
    • Tribu
#2928
  0
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.
Bolodefchoco
« Sénateur »
1533354960000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2929
  2
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua
Campwolf
« Citoyen »
1533403380000
    • Campwolf#8695
    • Profil
    • Derniers messages
    • Tribu
#2930
  0
Bolodefchoco a dit :
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua

How did the #transform module get exported?
Bolodefchoco
« Sénateur »
1533404460000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2931
  2
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua

How did the #transform module get exported?

You need to write it yourself.

The module is like:

When you press 1, save your current position, kill you and add a shaman object.
Press space and remove the shaman object, respawn you and move you to the saved position
Campwolf
« Citoyen »
1533415680000
    • Campwolf#8695
    • Profil
    • Derniers messages
    • Tribu
#2932
  0
Bolodefchoco a dit :
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua

How did the #transform module get exported?

You need to write it yourself.

The module is like:

When you press 1, save your current position, kill you and add a shaman object.
Press space and remove the shaman object, respawn you and move you to the saved position

Hmm, I don't understand
Bolodefchoco
« Sénateur »
1533416940000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2933
  2
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua

How did the #transform module get exported?

You need to write it yourself.

The module is like:

When you press 1, save your current position, kill you and add a shaman object.
Press space and remove the shaman object, respawn you and move you to the saved position

Hmm, I don't understand

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
local player_info = {}

eventNewGame = function()
-- Resets the players info
player_info = { }

for player in next, tfm.get.room.playerList do
player_info[player] = {
isObject = false,
objectId = -1
}
end
end

eventNewPlayer = function(player)
system.bindKeyboard(player, 32, true, true) -- Spacebar key
end
-- For all the players already in the room, do the same the script does for the player that just joined the room
table.foreach(tfm.get.room.playerList, eventNewPlayer)

eventKeyboard = function(player, key, _, x, y)
if not player_info[player] then
-- If you don't have that table, skip this event
return
end

if key == 32 then -- When the player press 32 (spacebar)
player_info[player].isObject = not player_info[player].isObject -- true becomes false, false becomes true

if player_info[player].isObject then
-- Gets the current player data, so we can use its velocity
local playerData = tfm.get.room.playerList[player]

-- If you are object, let's add the object
tfm.exec.killPlayer(player)

player_info[player].objectId = tfm.exec.addShamanObject(6, x, y, 0, playerData.vx, playerData.vy) -- Add it to the variable so we can remove it later
else
-- Gets the current shaman object, so we can use the x, y, and velocities.
local object = tfm.get.room.objectList[player_info[player].objectId]

-- If you are not an object, remove it
tfm.exec.removeObject(player_info[player].objectId)

tfm.exec.respawnPlayer(player)

tfm.exec.movePlayer(player, object.x, object.y, false, object.vx, object.vy)
end
end
end

tfm.exec.disableAutoShaman()
tfm.exec.disableAutoNewGame()
tfm.exec.newGame("#7")
Syrius
« Consul »
1533478200000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2934
  0
Script for textarea's callback to change table's SETUP's value (SETUP.challengemode) to "survival"
Campwolf
« Citoyen »
1533496140000
    • Campwolf#8695
    • Profil
    • Derniers messages
    • Tribu
#2935
  0
Bolodefchoco a dit :
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Bolodefchoco a dit :
Campwolf a dit :
Hi, recently I've been learning how to code on Lua. Can you tell me how I give transform powers? We don't have the module transform on my server.

hey, you can't give transform powers using lua

How did the #transform module get exported?

You need to write it yourself.

The module is like:

When you press 1, save your current position, kill you and add a shaman object.
Press space and remove the shaman object, respawn you and move you to the saved position

Hmm, I don't understand

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
local player_info = {}

eventNewGame = function()
-- Resets the players info
player_info = { }

for player in next, tfm.get.room.playerList do
player_info[player] = {
isObject = false,
objectId = -1
}
end
end

eventNewPlayer = function(player)
system.bindKeyboard(player, 32, true, true) -- Spacebar key
end
-- For all the players already in the room, do the same the script does for the player that just joined the room
table.foreach(tfm.get.room.playerList, eventNewPlayer)

eventKeyboard = function(player, key, _, x, y)
if not player_info[player] then
-- If you don't have that table, skip this event
return
end

if key == 32 then -- When the player press 32 (spacebar)
player_info[player].isObject = not player_info[player].isObject -- true becomes false, false becomes true

if player_info[player].isObject then
-- Gets the current player data, so we can use its velocity
local playerData = tfm.get.room.playerList[player]

-- If you are object, let's add the object
tfm.exec.killPlayer(player)

player_info[player].objectId = tfm.exec.addShamanObject(6, x, y, 0, playerData.vx, playerData.vy) -- Add it to the variable so we can remove it later
else
-- Gets the current shaman object, so we can use the x, y, and velocities.
local object = tfm.get.room.objectList[player_info[player].objectId]

-- If you are not an object, remove it
tfm.exec.removeObject(player_info[player].objectId)

tfm.exec.respawnPlayer(player)

tfm.exec.movePlayer(player, object.x, object.y, false, object.vx, object.vy)
end
end
end

tfm.exec.disableAutoShaman()
tfm.exec.disableAutoNewGame()
tfm.exec.newGame("#7")

Thank you!!
Themiachale
« Citoyen »
1534104720000
    • Themiachale#0000
    • Profil
    • Derniers messages
    • Tribu
#2936
  1
Someone maybe already did this but, can somebody do a script where:

You go on the water, you die?

I need to attach it to this script made by Velspar...

rh = 400 --The maps height
rw = 800 --The maps width
speed = 1 --The speed in which the water will rise.
------------------------------
--##Careful with large maps, can become quite laggy if your pc cant handle it.
------------------------------
bn = 0
function eventLoop()
bn = bn + speed
if bn > rh then bn = 0 end
tfm.exec.addPhysicObject(0,rw/2,rh-(bn/2),{
type=9,
width=rw,
height=bn,
foreground=true,
miceCollision=false
})
end
Bolodefchoco
« Sénateur »
1534116660000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2937
  2
Themiachale a dit :
You go on the water, you die?

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
-- Must not be a vanilla map

local water_grounds = { }
eventNewGame = function()
water_grounds = { }

local xml = (tfm.get.room.xmlMapInfo or { }).xml
if xml then
local total = 0
string.gsub(xml, "<S (.-)>", function(data)
if string.match(data, "T=\"(%d+)\"") == '9' then -- is water
local x, y, w, h

x = tonumber(string.match(data, "X=\"(%d+)\""))
y = tonumber(string.match(data, "Y=\"(%d+)\""))
w = tonumber(string.match(data, "L=\"(%d+)\""))
h = tonumber(string.match(data, "H=\"(%d+)\""))

if x and y and w and h then -- never trust match
total = total + 1

w = w / 2
h = h / 2

water_grounds[total] = { x - w, x + w, y - h, y + h } -- bounds
end
end
end)
end
end

eventLoop = function(currentTime)
if currentTime > 3000 then
for playerName, playerData in next, tfm.get.room.playerList do
if not playerData.isDead then
for _, water in next, water_grounds do
if playerData.x >= water[1] and playerData.x <= water[2] then
if playerData.y >= water[3] and playerData.y <= water[4] then
tfm.exec.killPlayer(playerName)
end
end
end
end
end
end
end

tfm.exec.newGame("#7")
Themiachale
« Citoyen »
1534119060000
    • Themiachale#0000
    • Profil
    • Derniers messages
    • Tribu
#2938
  0
Bolodefchoco a dit :
Themiachale a dit :
You go on the water, you die?

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
-- Must not be a vanilla map

local water_grounds = { }
eventNewGame = function()
water_grounds = { }

local xml = (tfm.get.room.xmlMapInfo or { }).xml
if xml then
local total = 0
string.gsub(xml, "<S (.-)>", function(data)
if string.match(data, "T=\"(%d+)\"") == '9' then -- is water
local x, y, w, h

x = tonumber(string.match(data, "X=\"(%d+)\""))
y = tonumber(string.match(data, "Y=\"(%d+)\""))
w = tonumber(string.match(data, "L=\"(%d+)\""))
h = tonumber(string.match(data, "H=\"(%d+)\""))

if x and y and w and h then -- never trust match
total = total + 1

w = w / 2
h = h / 2

water_grounds[total] = { x - w, x + w, y - h, y + h } -- bounds
end
end
end)
end
end

eventLoop = function(currentTime)
if currentTime > 3000 then
for playerName, playerData in next, tfm.get.room.playerList do
if not playerData.isDead then
for _, water in next, water_grounds do
if playerData.x >= water[1] and playerData.x <= water[2] then
if playerData.y >= water[3] and playerData.y <= water[4] then
tfm.exec.killPlayer(playerName)
end
end
end
end
end
end
end

tfm.exec.newGame("#7")

I'm sorry but I can't let it work properly... when I run it, it do the normal things that it could do when there wasn't this part of the script, the mice don't die while touching the water... Idk if I need to change something, could you help me more?

tfm.exec.disableAfkDeath(true)
tfm.exec.disableAutoShaman(true)
tfm.exec.newGame("@7493263")

-- Must not be a vanilla map

local water_grounds = { }
eventNewGame = function()
water_grounds = { }

local xml = (tfm.get.room.xmlMapInfo or { }).xml
if xml then
local total = 0
string.gsub(xml, "<S (.-)>", function(data)
if string.match(data, "T=\"(%d+)\"") == '9' then -- is water
local x, y, w, h

x = tonumber(string.match(data, "X=\"(%d+)\""))
y = tonumber(string.match(data, "Y=\"(%d+)\""))
w = tonumber(string.match(data, "L=\"(%d+)\""))
h = tonumber(string.match(data, "H=\"(%d+)\""))

if x and y and w and h then -- never trust match
total = total + 1

w = w / 2
h = h / 2

water_grounds[total] = { x - w, x + w, y - h, y + h } -- bounds
end
end
end)
end
end

eventLoop = function(currentTime)
if currentTime > 3000 then
for playerName, playerData in next, tfm.get.room.playerList do
if not playerData.isDead then
for _, water in next, water_grounds do
if playerData.x >= water[1] and playerData.x <= water[2] then
if playerData.y >= water[3] and playerData.y <= water[4] then
tfm.exec.killPlayer(playerName)
end
end
end
end
end
end
end


rh = 400 --The maps height
rw = 800 --The maps width
speed = 3 --The speed in which the water will rise.
------------------------------
--##Careful with large maps, can become quite laggy if your pc cant handle it.
------------------------------
bn = 0
function eventLoop()
bn = bn + speed
if bn > rh then bn = 0 end
tfm.exec.addPhysicObject(0,rw/2,rh-(bn/2),{
type=9,
width=rw,
height=bn,
foreground=true,
miceCollision=false
})
end


This is how I lightly changed the script...


e: I found out that it works, but the water that rise is not considered water, how can I change the script to consider it water?

Dernière modification le 1534120020000
Bolodefchoco
« Sénateur »
1534120620000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2939
  3
The script detects every single water ground. ^


Code

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
local water_grounds = { }
eventNewGame = function()
water_grounds = { }

local xml = (tfm.get.room.xmlMapInfo or { }).xml
if xml then
local total = 0
string.gsub(xml, "<S (.-)>", function(data)
if string.match(data, "T=\"(%d+)\"") == '9' then -- is water
local x, y, w, h

x = tonumber(string.match(data, "X=\"(%d+)\""))
y = tonumber(string.match(data, "Y=\"(%d+)\""))
w = tonumber(string.match(data, "L=\"(%d+)\""))
h = tonumber(string.match(data, "H=\"(%d+)\""))

if x and y and w and h then -- never trust match
total = total + 1

w = w / 2
h = h / 2

water_grounds[total] = { x - w, x + w, y - h, y + h } -- bounds
end
end
end)
end
end

rh = 400 --The maps height
rw = 800 --The maps width
speed = 3 --The speed in which the water will rise.
------------------------------
--##Careful with large maps, can become quite laggy if your pc cant handle it.
------------------------------
bn = 0
function eventLoop(currentTime)
bn = bn + speed
if bn > rh then bn = 0 end
tfm.exec.addPhysicObject(0,rw/2,rh-(bn/2),{
type=9,
width=rw,
height=bn,
foreground=true,
miceCollision=false
})

if currentTime > 3000 then
for playerName, playerData in next, tfm.get.room.playerList do
if not playerData.isDead then
for _, water in next, water_grounds do
if playerData.x >= water[1] and playerData.x <= water[2] then
if playerData.y >= water[3] and playerData.y <= water[4] then
tfm.exec.killPlayer(playerName)
end
end
end
end
end
end
end



Oh.. I just noticed they are not waters in the XML. The script only works in waters that are in the XML :P

Dernière modification le 1534120740000
Themiachale
« Citoyen »
1534121640000
    • Themiachale#0000
    • Profil
    • Derniers messages
    • Tribu
#2940
  0
Bolodefchoco a dit :
Oh.. I just noticed they are not waters in the XML. The script only works in waters that are in the XML :P

Oh ok, sorry for wasting your time, thank you anyways :3
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Script Requests
« ‹ 147 / 160 › »
© Atelier801 2018

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

Version 1.27