×

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
« ‹ 134 / 160 › »
Script Requests
Syrius
« Consul »
1516293780000
    • Syrius#8114
    • Profil
    • Derniers messages
    • Tribu
#2661
  0
How to make text area only show content for players in mod = {} table?
(what's the syntax? [mod] or what?)
Heniyengui
« Citoyen »
1516299600000
    • Heniyengui#0000
    • Profil
    • Derniers messages
#2662
  0
Marciskris a dit :
How to make text area only show content for players in mod = {} table?
(what's the syntax? [mod] or what?)

Code Lua

1
2
3
4
 mod = { Marciskris = true } 
for name in pairs(mod) do
ui.addTextArea(0,"text", name, 100, 200, 100, 50, 0xffffff, 0xffffff, 1, true)
end
Bolodefchoco
« Sénateur »
1516299900000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2663
  0
Marciskris a dit :
How to make text area only show content for players in mod = {} table?
(what's the syntax? [mod] or what?)

You can use the for index, value in next, table_name do statement which works like the foreach in C#, Java, etc... Note that pairs(table) returns next, table, nil, and you can also use ipairs(table) to iterate only numeric indexes.
You can also concatenate all the items of the table by using the function table.concat(table_name, separator), e.g., table.concat(mod, ", ")

Dernière modification le 1516300020000
Heniyengui
« Citoyen »
1516381020000
    • Heniyengui#0000
    • Profil
    • Derniers messages
#2664
  0
is there a function I can create to get the mouse position ( x and y) ? (that is better than the tfm.get.room.playerList[name].x)
because tfm.get.room.playerList[name].x or y only update info every 2 seconds.
Bolodefchoco
« Sénateur »
1516383960000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2665
  0
Heniyengui a dit :
is there a function I can create to get the mouse position ( x and y) ? (that is better than the tfm.get.room.playerList[name].x)
because tfm.get.room.playerList[name].x or y only update info every 2 seconds.

Unfortunately the source of the coordinates are these indexes, but you can use this trick:

Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
eventNewPlayer = function(player)
for key = 0, 255 do
for bind = 0, 1 do
-- Bind all the keys
system.bindKeyboard(player, key, bind == 0, true)
end
end
end
-- Same for the players in the room
table.foreach(tfm.get.room.playerList, eventNewPlayer)

eventKeyboard = function(player, key, down, x, y)
-- No matter if it was hold/release or what key, the (x,y) is precise!
tfm.get.room.playerList[player].x = x
tfm.get.room.playerList[player].y = y
end
Heniyengui
« Citoyen »
1516385400000
    • Heniyengui#0000
    • Profil
    • Derniers messages
#2666
  0
Bolodefchoco a dit :
Heniyengui a dit :
is there a function I can create to get the mouse position ( x and y) ? (that is better than the tfm.get.room.playerList[name].x)
because tfm.get.room.playerList[name].x or y only update info every 2 seconds.

Unfortunately the source of the coordinates are these indexes, but you can use this trick:
*LUA CODE*

Are you sure this works? I think you can't bind the key when it's hold or released, I mean, for example, in your script all the keys will be bind when down = false, I am not sure tho. Thank you anyway, I will try it :)
Bolodefchoco
« Sénateur »
1516386600000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2667
  0
Heniyengui a dit :
Bolodefchoco a dit :
Heniyengui a dit :
is there a function I can create to get the mouse position ( x and y) ? (that is better than the tfm.get.room.playerList[name].x)
because tfm.get.room.playerList[name].x or y only update info every 2 seconds.

Unfortunately the source of the coordinates are these indexes, but you can use this trick:
*LUA CODE*

Are you sure this works? I think you can't bind the key when it's hold or released, I mean, for example, in your script all the keys will be bind when down = false, I am not sure tho. Thank you anyway, I will try it :)

system.bindKeyboard(name, key, boolean released, boolean active)
The second loop binds it both pressed and released, so eventKeyboard is triggered during a press and a release
Borntolol
« Citoyen »
1516473000000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2668
  0
how would i make it so it would do this

If mice > 4
[module script here]
else
If mice < 5
set map [map here] until mice > 4

Dernière modification le 1516473060000
Bolodefchoco
« Sénateur »
1516473420000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2669
  0
Borntolol a dit :
how would i make it so it would do this

If mice > 4
[module script here]
else
If mice < 5
set map [map here] until mice > 4

So, you want to make a 'wait' until enough mice, or kinda..
Well, you'll need to use a loop!

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
countMice = function()
local total = 0
for k in next, tfm.get.room.playerList do
total = total + 1
end
return total
end

isWaiting = false

-- Triggered twice per second
eventLoop = function()
local totalMice = countMice()
if totalMice > 4 then
if isWaiting then
isWaiting = false
print("Now it has more than 4 mice!")
end

-- TODO Module script

else -- <= 4

-- This if is needed, otherwise there'll be a newGame every single time
if not isWaiting then
isWaiting = true
tfm.exec.newGame("@0")
print("The room has less than 5 mice")
end

end
end

Dernière modification le 1516473480000
Borntolol
« Citoyen »
1516473720000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2670
  0
thanks :D, Ill probably come back with another request later xD
Borntolol
« Citoyen »
1516474200000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2671
  0
Noob question:
When in lobby ( the map when theres less than # mice )
how to disable the timer, sham and afk death
Bolodefchoco
« Sénateur »
1516474680000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2672
  0
Borntolol a dit :
thanks :D, Ill probably come back with another request later xD

Feel free to ask ^_^


Borntolol a dit :
Noob question:
When in lobby ( the map when theres less than # mice )
how to disable the timer, sham and afk death

tfm.exec.disableAutoNewGame()
tfm.exec.disableAutoShaman() -- Before the newGame!
tfm.exec.disableAutoAfkDeath()

You can check all the "disable" functions using
Code Lua

1
2
3
for k in next, tfm.exec do
if k:find("disable") then print(k) end
end

To enable them, just set the parameter as "(false)", instead of "()"
Borntolol
« Citoyen »
1516474740000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2673
  0
what does "k" mean in all these scripts tho
Bolodefchoco
« Sénateur »
1516474860000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2674
  0
Borntolol a dit :
what does "k" mean in all these scripts tho

It's just a variable name I set in the for. Do you come from any other language or you are a beginner? So I can help you in a different way.

Anyways, the for syntax is
Code Lua

1
2
3
for table_index, table_value in next, table_name do
print("The table table_name has the value " .. tostring(table_value) .. " in the index " .. table_index)
end
So, you can call " k " as "index", "functionName", "banana", anything ^^'
The standards are k,v m,n i,j
Borntolol
« Citoyen »
1516474920000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2675
  0
o
i only use basic coding and thats all
never used lua before ^-^
Bolodefchoco
« Sénateur »
1516475040000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2676
  0
Borntolol a dit :
o
i only use basic coding and thats all
never used lua before ^-^

Oh, I see, but what was the programming language?
Borntolol
« Citoyen »
1516475460000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2677
  0
Im not entirely sure,
also the print "" doesnt seem to work
Bolodefchoco
« Sénateur »
1516475760000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#2678
  0
Borntolol a dit :
Im not entirely sure,
also the print "" doesnt seem to work

with table_name?
Create a variable before the for..
table_name = {3, 4, 5, a = 1, b = 2,}
btw table_name was just an example ^^
• [17:17] # [*Santa's Workshop] The table table_name has the value 3 in the index 1
• [17:17] # [*Santa's Workshop] The table table_name has the value 4 in the index 2
• [17:17] # [*Santa's Workshop] The table table_name has the value 5 in the index 3
• [17:17] # [*Santa's Workshop] The table table_name has the value 1 in the index a
• [17:17] # [*Santa's Workshop] The table table_name has the value 2 in the index b

Dernière modification le 1516475820000
Borntolol
« Citoyen »
1516475880000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2679
  0
I meant on this part
if not isWaiting then
isWaiting = true
tfm.exec.disableAutoShaman()
tfm.exec.newGame("@7366519")
tfm.exec.disableAutoNewGame()
print("5 mice is needed for start")
Borntolol
« Citoyen »
1516476960000
    • Borntolol#0000
    • Profil
    • Derniers messages
    • Tribu
#2680
  0
no solution for it i guess?
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • Script Requests
« ‹ 134 / 160 › »
© Atelier801 2018

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

Version 1.27