×

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
« ‹ 146 / 160 › »
Script Requests
Onkei
« Citoyen »
1531833300000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#2901
  0
Overjoy06 a dit :
how do you make the blue team fly (they are vampires and also why cant i make the vampire fly? the recent vamped mices wont fly)

--sorry for bad grammar :(

untested, not sure if this is what you mean


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 red, blue = {}, {}

function randomTeams()

-- Same as Fxie's team generator but more commented.

red, blue = {}, {}

-- Putting all the players in the room into a table to be randomised.
local allPlayers = {}

for n in next, tfm.get.room.playerList do
table.insert(allPlayers, n)
end

for loopNumber = 1, #allPlayers do
-- Getting a random index to a player
local randomIndex = math.random(#allPlayers)
local player = allPlayers[randomIndex]

if loopNumber % 2 == 0 then
red[player] = true
else
blue[player] = true
end

table.remove(allPlayers, randomIndex)
end
end

function eventNewGame()

randomTeams()

for n in next, tfm.get.room.playerList do
-- If player is in the blue team then they can fly/vamp.

if red[n] then
system.bindKeyboard(n, 32, true, false)
elseif blue[n] then
tfm.exec.setVampirePlayer(n)
system.bindKeyboard(n, 32, true, true)
end
end
end

function eventKeyboard(n, key, down, x, y)

if y > 0 then
tfm.exec.movePlayer(n, 0, 0, true, 0, -50, false)
end
end

eventNewGame()
Syrius
« Consul »
1531918140000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2902
  0
Script that print()'s mouse cursor's coordinates if "E" is pressed.
Bolodefchoco
« Sénateur »
1531919580000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2903
  0
Syrius a dit :
Script that print()'s mouse cursor's coordinates if "E" is pressed.

You can't get the current coordinate, only when the player clicks
Syrius
« Consul »
1531981560000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2904
  0
Okay, can then instead that can be done with shift+click? (or if that can't be done then click)
Onkei
« Citoyen »
1531990500000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#2905
  0
Syrius a dit :
Okay, can then instead that can be done with shift+click? (or if that can't be done then click)


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
local SHIFT_KEY = 16

-- Table to store whether a player is holding shift or not
local shifting = {}

function eventNewPlayer(n)

shifting[n] = false

system.bindKeyboard(n, SHIFT_KEY, true, true)
system.bindKeyboard(n, SHIFT_KEY, false, true)
system.bindMouse(n, true)
end

function eventKeyboard(n, key, down, x, y)

shifting[n] = down -- True if shift is being held
end

function eventMouse(n, x, y)

if shifting[n] then
print(n .. "'s current mouse coordinate is at: X" .. x .. " Y" .. y)
end
end

table.foreach(tfm.get.room.playerList, eventNewPlayer)
Overjoy06
« Citoyen »
1532090640000
    • Overjoy06#8554
    • Profil
    • Derniers messages
    • Tribu
#2906
  0
How can i disable the vampires from shooting arrows
The code i used :
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
local arrows = {}
local MAX_ARROWS = 5
local ARROW_FORCE = 24

local timer = 0
local TIMER_LOOPAT = 8

function showArrows(n)
ui.addTextArea(0, "<font size='20'>Arrows: " .. arrows[n], n, 10, 20, nil, nil, 0x000000, 0x2e2e2e, 0.6, true)
end

function eventNewPlayer(n)
arrows[n] = MAX_ARROWS

showArrows(n)
system.bindMouse(n, true)
end

function eventMouse(n, x, y)
local data = tfm.get.room.playerList[n]

if not data.isDead and arrows[n] > 0 then
local angle = math.atan2(y - data.y, x - data.x)

tfm.exec.addShamanObject(
35,
data.x + 50 * math.cos(angle),
data.y + 50 * math.sin(angle),
math.deg(angle),
math.cos(angle) * ARROW_FORCE,
math.sin(angle) * ARROW_FORCE
)

arrows[n] = arrows[n] - 1
showArrows(n)
end
end

table.foreach(tfm.get.room.playerList, eventNewPlayer)
Onkei
« Citoyen »
1532145900000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#2907
  0
Overjoy06 a dit :
How can i disable the vampires from shooting arrows

this should do the trick


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
local arrows = {}
local MAX_ARROWS = 5
local ARROW_FORCE = 24

local timer = 0
local TIMER_LOOPAT = 8

function showArrows(n)
ui.addTextArea(0, "<font size='20'>Arrows: " .. arrows[n], n, 10, 20, nil, nil, 0x000000, 0x2e2e2e, 0.6, true)
end

function eventNewPlayer(n)
arrows[n] = MAX_ARROWS

showArrows(n)
system.bindMouse(n, true)
end

function eventMouse(n, x, y)
local data = tfm.get.room.playerList[n]

if not data.isDead and not data.isVampire and arrows[n] > 0 then
local angle = math.atan2(y - data.y, x - data.x)

tfm.exec.addShamanObject(
35,
data.x + 50 * math.cos(angle),
data.y + 50 * math.sin(angle),
math.deg(angle),
math.cos(angle) * ARROW_FORCE,
math.sin(angle) * ARROW_FORCE
)

arrows[n] = arrows[n] - 1
showArrows(n)
end
end

table.foreach(tfm.get.room.playerList, eventNewPlayer)
Overjoy06
« Citoyen »
1532169720000
    • Overjoy06#0000
    • Profil
    • Derniers messages
    • Tribu
#2908
  0
But the textarea is still visible to the vampires
Onkei
« Citoyen »
1532171760000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#2909
  0
Overjoy06 a dit :
But the textarea is still visible to the vampires

if this doesn't work, please provide the whole code that you're working with


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
local arrows = {}
local MAX_ARROWS = 5
local ARROW_FORCE = 24

local timer = 0
local TIMER_LOOPAT = 8

function showArrows(n)
if not tfm.get.room.playerList[n].isVampire then
ui.addTextArea(0, "<font size='20'>Arrows: " .. arrows[n], n, 10, 20, nil, nil, 0x000000, 0x2e2e2e, 0.6, true)
end
end

function eventNewPlayer(n)
arrows[n] = MAX_ARROWS

showArrows(n)
system.bindMouse(n, true)
end

function eventMouse(n, x, y)
local data = tfm.get.room.playerList[n]

if not data.isDead and not data.isVampire and arrows[n] > 0 then
local angle = math.atan2(y - data.y, x - data.x)

tfm.exec.addShamanObject(
35,
data.x + 50 * math.cos(angle),
data.y + 50 * math.sin(angle),
math.deg(angle),
math.cos(angle) * ARROW_FORCE,
math.sin(angle) * ARROW_FORCE
)

arrows[n] = arrows[n] - 1
showArrows(n)
end
end

table.foreach(tfm.get.room.playerList, eventNewPlayer)
Mainabg
« Citoyen »
1532173320000
    • Mainabg#7566
    • Profil
    • Derniers messages
#2910
  0
In unotfm theres a card when you play it, it will show a emote and you have to click it or you will get cards

But what if someone (by someone i meant a RandomPlayer) click a TextArea that says "Dance" when the person clicked it the other mices have to dance if they dont they get killed.

Also is there a code that when you type !win you win

Dernière modification le 1532173380000
Dagaker
« Censeur »
1532183100000
    • Dagaker#3257
    • Profil
    • Derniers messages
#2911
  0
I need a script that will allow me to spawn a ground and change it size.
Syrius
« Consul »
1532250000000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2912
  0
Script that determines the last one standing (need it for survival challenge) and executes a function for winner.
Bolodefchoco
« Sénateur »
1532266500000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2913
  0
Syrius a dit :
Script that determines the last one standing (need it for survival challenge) and executes a function for winner.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local winnerFunction = function(winner)
print(winner .. " win !")
end

eventLoop = function()
local winner
for k, v in next, tfm.get.room.playerList do
if not v.isDead then
if winner then
return
else
winner = k
end
end
end

winnerFunction(winner)
end

Dernière modification le 1532266680000
Syrius
« Consul »
1532336760000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2914
  0
What's the syntax for table parameters?

If I have table SETUP = {flymode=false,challengemode=default,challengersonly=true} then how do I make a certain section of the code ran only if challengemode=survival?

I tried if SETUP.challengemode=survival then (function here) end - but that doesn't work: if says that it expects then, but I already have it.
Syrius
« Consul »
1532342160000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2915
  0
Bolodefchoco a dit :
Syrius a dit :
Script that determines the last one standing (need it for survival challenge) and executes a function for winner.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local winnerFunction = function(winner)
print(winner .. " win !")
end

eventLoop = function()
local winner
for k, v in next, tfm.get.room.playerList do
if not v.isDead then
if winner then
return
else
winner = k
end
end
end

winnerFunction(winner)
end

Also, the script certainly does something, but after that it enters infinite loop, crashing the script if ..winner.. is used in print or textarea. Using it in playervicory or givecheese results in major "Argument error" spam.
Heniyengui
« Citoyen »
1532349240000
    • Heniyengui#0000
    • Profil
    • Derniers messages
#2916
  0
Not tested, but should work.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function winnerFunction(winner)
print(winner.." won!")
end
function eventPlayerDied(name)
local count, winner = 0
for k, v in next, tfm.get.room.playerList do
if not v.isDead then
count = count + 1
winner = k
end
end
if count == 1 then
winnerFunction(winner)
end
end
Heniyengui
« Citoyen »
1532349420000
    • Heniyengui#0000
    • Profil
    • Derniers messages
#2917
  0
Edit: Sorry for the double post. my bad.

Syrius a dit :
What's the syntax for table parameters?

If I have table SETUP = {flymode=false,challengemode=default,challengersonly=true} then how do I make a certain section of the code ran only if challengemode=survival?

I tried if SETUP.challengemode=survival then (function here) end - but that doesn't work: if says that it expects then, but I already have it.

Not sure if that's what you want:

Code Lua

1
2
3
if SETUP.challengemode == "survival" then
runSurvival()
end

The "then expected" error you got was because you did "if a = b then". To compare values you need to use "if a == b then".

Dernière modification le 1532349540000
Syrius
« Consul »
1532352480000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2918
  0
Oh, okay.
Bolodefchoco
« Sénateur »
1532355660000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2919
  0
Syrius a dit :
Bolodefchoco a dit :
Syrius a dit :
Script that determines the last one standing (need it for survival challenge) and executes a function for winner.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local winnerFunction = function(winner)
print(winner .. " win !")
end

eventLoop = function()
local winner
for k, v in next, tfm.get.room.playerList do
if not v.isDead then
if winner then
return
else
winner = k
end
end
end

winnerFunction(winner)
end

Also, the script certainly does something, but after that it enters infinite loop, crashing the script if ..winner.. is used in print or textarea. Using it in playervicory or givecheese results in major "Argument error" spam.

I wrote the winner system only, you should put a new game or something else, depending on what your game does.


If you are use to do a value attribution in an if, just like in C#
Code CS

1
2
boolean a = false, b = true;
if (a = b) { }
Unfortunately you'll have to make it bigger in lua
Code Lua

1
2
3
local a, b = false, true
a = b
if a == b then

Heniyengui a dit :
Not tested, but should work.

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function winnerFunction(winner)
print(winner.." won!")
end
function eventPlayerDied(name)
local count, winner = 0
for k, v in next, tfm.get.room.playerList do
if not v.isDead then
count = count + 1
winner = k
end
end
if count == 1 then
winnerFunction(winner)
end
end

It would still loop

Dernière modification le 1532355720000
Syrius
« Consul »
1532377740000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2920
  0
How to make multiple arguments after command?
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Script Requests
« ‹ 146 / 160 › »
© Atelier801 2018

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

Version 1.27