×

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
« ‹ 156 / 160 › »
Script Requests
Aen_elle
« Citoyen »
1582454460000
    • Aen_elle#0000
    • Profil
    • Derniers messages
    • Tribu
#3101
  0
Bolodefchoco a dit :
Aen_elle a dit :
Hi,
Don't find a specific theme, so:
1) Any way to show different information in textArea for different players?
2) Have a script that add shamanObject every click, and delete previous obj with that id:
1
2
tfm.exec.removeObject(id)
id=tfm.exec.addShamanObject(6,xMousePosition,yMousePosition,0,let_power,let_power,false)
Any way to create different id for different playerName? (mean that different players will not delete each other's objects)
3) Any event for object, when it have some coordinates? (for example, box spawn at some area trigger an event)

Does #module team have access to functions, except events that we can find here? or is it the maximum development opportunity for mere mortals usual players?

Hello!

1) Textareas can be displayed to specific players by passing their nickname as third parameter, example:
Code Lua

1
2
3
ui.addTextArea(0, "Text A", "Bolodefchoco#0000", 10, 10, nil, nil, 1, 1, 1, true) -- This textarea only appears to me
ui.addTextArea(1, "Text B", "Aen_elle#0000", 10, 50, nil, nil, 1, 1, 1, true) -- This textarea only appears to you
ui.addTextArea(2, "Text C", nil, 10, 100, nil, nil, 1, 1, 1, true) -- This textarea appears to everyone

2) You need to attach the id to the player's nickname, use a table for that.
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local playerData = { } -- where the ids will be located

eventNewPlayer = function(playerName) -- event when someone joins the room
system.bindMouse(playerName, true) -- allow this player to click
end
for playerName in next, tfm.get.room.playerList -- gets all players that are already in the room
eventNewPlayer(playerName) -- and does the same things as if they just had joined the room
end

eventMouse = function(playerName, x, y) -- event when a player clicks
if playerData[playerName] then -- checks if there is an ID attached to that nickname
tfm.exec.removeObject(playerData[playerName]) -- if so, removes the object
end

playerData[playerName] = tfm.exec.addShamanObject(6, x, y) -- creates a new object and attachs the returned id to the player name
end

-- Optional
eventNewGame = function()
playerData = { } -- resets the playerData table because all objects (IDs) of the previous map were automatically removed by the game
end

3) You need to use eventSummoningEnd (when an object has spawned by the shaman)

Code Lua

1
2
3
4
5
eventSummoningEnd = function(playerName, objectType, x, y)
if x >= 10 and x <= 60 then
print("the object has been spawned between the X coordinates 10 and 60")
end
end

You can use the same x and y logic in eventMouse or any other similar chunk

About the functions, kinda yes. That thread is pretty outdated. Check The official one to get to know about all functions and events.

The module team have them all and nothing more. :(



Thanks!

Incorrectly formulated the third question: I have some shamanObject, that may enter specific area few seconds after it was spawned. Is it possible to track the moment of getting into this area? (Something like mini-game, mice have hit the ball in the basket; need to count the hit)
Koelman1
« Citoyen »
1582463640000
    • Koelman1#0000
    • Profil
    • Derniers messages
#3102
  0
Hi!
I write because I need code to reduce / increase player size. I used to use it, but I lost it somewhere / I forgot to save.
It is best to choose a value from 0.1x to 5x.
Thank you in advance <3
Bolodefchoco
« Sénateur »
1582467660000
    • Bolodefchoco#0095
    • Profil
    • Derniers messages
    • Tribu
#3103
  1
Koelman1 a dit :
Hi!
I write because I need code to reduce / increase player size. I used to use it, but I lost it somewhere / I forgot to save.
It is best to choose a value from 0.1x to 5x.
Thank you in advance <3

tfm.exec.changePlayerSize(playerName, size)


Aen_elle a dit :
Bolodefchoco a dit :
Aen_elle a dit :
Hi,
Don't find a specific theme, so:
1) Any way to show different information in textArea for different players?
2) Have a script that add shamanObject every click, and delete previous obj with that id:
1
2
tfm.exec.removeObject(id)
id=tfm.exec.addShamanObject(6,xMousePosition,yMousePosition,0,let_power,let_power,false)
Any way to create different id for different playerName? (mean that different players will not delete each other's objects)
3) Any event for object, when it have some coordinates? (for example, box spawn at some area trigger an event)

Does #module team have access to functions, except events that we can find here? or is it the maximum development opportunity for mere mortals usual players?

Hello!

1) Textareas can be displayed to specific players by passing their nickname as third parameter, example:
Code Lua

1
2
3
ui.addTextArea(0, "Text A", "Bolodefchoco#0000", 10, 10, nil, nil, 1, 1, 1, true) -- This textarea only appears to me
ui.addTextArea(1, "Text B", "Aen_elle#0000", 10, 50, nil, nil, 1, 1, 1, true) -- This textarea only appears to you
ui.addTextArea(2, "Text C", nil, 10, 100, nil, nil, 1, 1, 1, true) -- This textarea appears to everyone

2) You need to attach the id to the player's nickname, use a table for that.
Code Lua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local playerData = { } -- where the ids will be located

eventNewPlayer = function(playerName) -- event when someone joins the room
system.bindMouse(playerName, true) -- allow this player to click
end
for playerName in next, tfm.get.room.playerList -- gets all players that are already in the room
eventNewPlayer(playerName) -- and does the same things as if they just had joined the room
end

eventMouse = function(playerName, x, y) -- event when a player clicks
if playerData[playerName] then -- checks if there is an ID attached to that nickname
tfm.exec.removeObject(playerData[playerName]) -- if so, removes the object
end

playerData[playerName] = tfm.exec.addShamanObject(6, x, y) -- creates a new object and attachs the returned id to the player name
end

-- Optional
eventNewGame = function()
playerData = { } -- resets the playerData table because all objects (IDs) of the previous map were automatically removed by the game
end

3) You need to use eventSummoningEnd (when an object has spawned by the shaman)

Code Lua

1
2
3
4
5
eventSummoningEnd = function(playerName, objectType, x, y)
if x >= 10 and x <= 60 then
print("the object has been spawned between the X coordinates 10 and 60")
end
end

You can use the same x and y logic in eventMouse or any other similar chunk

About the functions, kinda yes. That thread is pretty outdated. Check The official one to get to know about all functions and events.

The module team have them all and nothing more. :(



Thanks!

Incorrectly formulated the third question: I have some shamanObject, that may enter specific area few seconds after it was spawned. Is it possible to track the moment of getting into this area? (Something like mini-game, mice have hit the ball in the basket; need to count the hit)

I see...

You can do something like this:
Code Lua

1
2
3
4
5
6
7
eventLoop = function() -- triggered twice per second
for _, obj in next, tfm.get.room.objectList do -- iters over all shaman objects in the map
if obj.x >= 10 and obj.x <= 60 then
print("The object of id " .. obj.id .. " is between x:10 and x:60")
end
end
end
Brandondito
« Citoyen »
1583705880000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3104
  0
hello, I need that by pressing space and if a mouse is close it kills it

Dernière modification le 1583705940000
Onkei
« Citoyen »
1583747880000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#3105
  0
Brandondito a dit :
hello, I need that by pressing space and if a mouse is close it kills it


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
local killer = "Brandondito#0000"

-- Set "EVERYONE = true" if you want everyone to be able to kill
local EVERYONE = false

local SPACE_KEY = 32
local MINIMUM_KILL_RANGE = 50

-- Checking if a certain coordinate is within the range of another coordinate
function withinRange(x1, y1, x2, y2, range)
local xDist = math.abs(x1 - x2)
local yDist = math.abs(y1 - y2)

if xDist < range and yDist < range then
return true
end

return false
end

-- If a player joins, bind their spacebar keyboard-key based on the configured settings.
function eventNewPlayer(name)

if EVERYONE or killer == name then
tfm.exec.bindKeyboard(name, SPACE_KEY, true, true)
end
end

-- Function provided by TFM's API. Occurs whenever someone presses a binded key.
function eventKeyboard(name, key, down, x, y)

if key == SPACE_KEY then
for _name, player in next, tfm.get.room.playerList do
if _name ~= name and withinRange(x, y, player.x, player.y, MINIMUM_KILL_RANGE) then
tfm.exec.killPlayer(_name)
end
end
end
end

-- For every player in the room, run eventNewPlayer on them.
-- tfm.get.room.playerList gives us a list of players in the room.
for name in next, tfm.get.room.playerList do
eventNewPlayer(name)
end
Brandondito
« Citoyen »
1583873580000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3106
  0
Thank you very much it's perfect

Dernière modification le 1583873640000
Brandondito
« Citoyen »
1583884560000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3107
  0
If it's not too much to ask, I could restrict the time to kill again for 10 seconds, thanks in advance
Onkei
« Citoyen »
1583921100000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#3108
  0
Brandondito a dit :
If it's not too much to ask, I could restrict the time to kill again for 10 seconds, thanks in advance


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
local killer = "Brandondito#0000"
local killerData = {}

local EVERYONE = false -- Set "EVERYONE = true" if you want everyone to be able to kill
local SPACE_KEY = 32
local MINIMUM_KILL_RANGE = 50
local KILL_ATTEMPT_COOLDOWN = 10000 -- 10s * 1000ms

-- Checking if a certain coordinate is within the range of another coordinate
function withinRange(x1, y1, x2, y2, range)
local xDist = math.abs(x1 - x2)
local yDist = math.abs(y1 - y2)

if xDist < range and yDist < range then
return true
end

return false
end

-- If a player joins, bind their spacebar keyboard-key based on the configured settings.
function eventNewPlayer(name)

if EVERYONE or killer == name then
-- Storing last kill attempt's timestamp to implement cooldown
killerData[name] = 0

tfm.exec.bindKeyboard(name, SPACE_KEY, true, true)
end
end

-- Function provided by TFM's API. Occurs whenever someone presses a binded key.
function eventKeyboard(name, key, down, x, y)

local now = os.time()

if key == SPACE_KEY and killerData[name] > now then
killerData[name] = now + KILL_ATTEMPT_COOLDOWN

for _name, player in next, tfm.get.room.playerList do
if _name ~= name and withinRange(x, y, player.x, player.y, MINIMUM_KILL_RANGE) then
tfm.exec.killPlayer(_name)
end
end
end
end

-- For every player in the room, run eventNewPlayer on them.
-- tfm.get.room.playerList gives us a list of players in the room.
for name in next, tfm.get.room.playerList do
eventNewPlayer(name)
end
Brandondito
« Citoyen »
1583934300000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3109
  0
Thank you so much for everything :)
Brandondito
« Citoyen »
1583935680000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3110
  0
it doesn't give any error but it doesn't work
Onkei
« Citoyen »
1583966880000
    • Onkei#0000
    • Profil
    • Derniers messages
    • Tribu
#3111
  0
Brandondito a dit :
it doesn't give any error but it doesn't work

Wops, made a typo, this should work now.


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
local killer = "Brandondito#0000"
local killerData = {}

local EVERYONE = false -- Set "EVERYONE = true" if you want everyone to be able to kill
local SPACE_KEY = 32
local MINIMUM_KILL_RANGE = 50
local KILL_ATTEMPT_COOLDOWN = 10000 -- 10s * 1000ms

-- Checking if a certain coordinate is within the range of another coordinate
function withinRange(x1, y1, x2, y2, range)
local xDist = math.abs(x1 - x2)
local yDist = math.abs(y1 - y2)

if xDist < range and yDist < range then
return true
end

return false
end

-- If a player joins, bind their spacebar keyboard-key based on the configured settings.
function eventNewPlayer(name)

if EVERYONE or killer == name then
-- Storing last kill attempt's timestamp to implement cooldown
killerData[name] = 0

tfm.exec.bindKeyboard(name, SPACE_KEY, true, true)
end
end

-- Function provided by TFM's API. Occurs whenever someone presses a binded key.
function eventKeyboard(name, key, down, x, y)

local now = os.time()

if key == SPACE_KEY and killerData[name] < now then
killerData[name] = now + KILL_ATTEMPT_COOLDOWN

for _name, player in next, tfm.get.room.playerList do
if _name ~= name and withinRange(x, y, player.x, player.y, MINIMUM_KILL_RANGE) then
tfm.exec.killPlayer(_name)
end
end
end
end

-- For every player in the room, run eventNewPlayer on them.
-- tfm.get.room.playerList gives us a list of players in the room.
for name in next, tfm.get.room.playerList do
eventNewPlayer(name)
end
Brandondito
« Citoyen »
1583970540000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3112
  0
thank you very much it will be very useful
Mouny
« Citoyen »
1584453060000
    • Mouny#6831
    • Profil
    • Derniers messages
    • Tribu
#3113
  0
Henlo, i want a scripte where you can shot arrows like in fortmice QwQ
Brandondito
« Citoyen »
1584670860000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3114
  0
Mouny a dit :
Henlo, i want a scripte where you can shot arrows like in fortmice QwQ

https://atelier801.com/topic?f=6&t=487197

it is almost identical to the module

Dernière modification le 1584670920000
Brandondito
« Citoyen »
1584826080000
    • Brandondito#0000
    • Profil
    • Derniers messages
#3115
  0
hello, i need a voting script that
-all mice can vote only once
-and that at the end of the time in the room kill the mouse with more votes

Thanks in advance
Liberrate
« Citoyen »
1585126140000
    • Liberrate#0000
    • Profil
    • Derniers messages
#3116
  0
Hello, is there any way to make part of map appearing for only one player, when he enters its place? I mean something like in village map, when we enter house we can see its interior, but only we. I think lua should modify xml code, but i cant understand how to make it, is it possible to dynamically modify map xml? And only for one player? (Sorry for my English)
Hypermousem
« Censeur »
1585153080000
    • Hypermousem#0000
    • Profil
    • Derniers messages
    • Tribu
#3117
  0
Liberrate a dit :
Hello, is there any way to make part of map appearing for only one player, when he enters its place? I mean something like in village map, when we enter house we can see its interior, but only we. I think lua should modify xml code, but i cant understand how to make it, is it possible to dynamically modify map xml? And only for one player? (Sorry for my English)

There is no way to dynamically edit XML directly using Lua without the need to reload the map, there are only ways to add/move/remove grounds and shaman objects (and those changes apply to every player). As for the village map, it uses the APS tag, which allows to create images that disappear when a mouse enters a certain rectangular area. I don't fully understand which value in the tag corresponds to what, but here's an example I created using Miceditor (which has that function useable through an interface):
Example: the statue disappears when you enter the area highlighted by the rectangle ground
Code Lua

1
2
tfm.exec.disableAutoNewGame(true)
tfm.exec.newGame('<C><P APS="x_transformice/x_evt/x_evt_26/elisah0.png,,250,120,200,200,596,-40"/><Z><S><S X="350" Y="220" T="12" L="200" H="200" o="324650" P="0,0,0.3,0.2,0,0,0,0" c="4"/><S X="400" Y="360" T="0" L="800" H="80" P="0,0,0.3,0.2,0,0,0,0"/></S><D><DS X="150" Y="305"/></D><O/><L/></Z></C>')
If you want a better explanation of the tag, you're more likely to get an answer in the Map Editor Q&A thread. Sadly, I think the tag can only be used when loading the map through Lua (from XML).

Dernière modification le 1585153740000
Liberrate
« Citoyen »
1585161480000
    • Liberrate#0000
    • Profil
    • Derniers messages
#3118
  0
Thank you so mach Hypermousem! I understand your code, I now can create images and grounds that hide these :) So much thanks!
I have another question, can I hide ground instead of picture? I know that I can make ground when I touch it it disappears, but it works for all people, not only for me. Is there any way for that?
Hypermousem
« Censeur »
1585163460000
    • Hypermousem#0000
    • Profil
    • Derniers messages
    • Tribu
#3119
  0
Liberrate a dit :
Thank you so mach Hypermousem! I understand your code, I now can create images and grounds that hide these :) So much thanks!
I have another question, can I hide ground instead of picture? I know that I can make ground when I touch it it disappears, but it works for all people, not only for me. Is there any way for that?

Sadly not, grounds being altered can only be applied to all players. If it's a matter of passing through a solid ground, you might want to try teleporting (tfm.exec.movePlayer) as an alternative. But I'm afraid what you described sadly isn't possible.
Liberrate
« Citoyen »
1585170420000
    • Liberrate#0000
    • Profil
    • Derniers messages
#3120
  0
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?

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

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

Version 1.27