×

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] Nightmode
[Script] Nightmode
Radioactium
« Citoyen »
1567553880000
    • Radioactium#0000
    • Profil
    • Derniers messages
    • Tribu
#1
  3
Unfortunately, I am too busy now to program on tfm to actually finish and debug all of my code, so most of my code is unfinished (I may come back to tfm one day though).

I don't expect this to get a lot of attention, but I'll post it here anyways.

Night Mode is simply just a small function originally meant for a bigger project (rewriting #traitor), but because of time constraints, only this function might end up to be a little useful someday (no idea if someone has come up with this idea before and made a thread about it, so if you did, sorry about that).

What Night Mode does is (hopefully) limit each player's "vision" (similar to the N="" parameter in map making).

Night mode

Night Mode Pastebin
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
tfm.exec.disableAutoTimeLeft(disable)
tfm.exec.disableAfkDeath(disable)
tfm.exec.newGame("@7640468")

createRing = function(playerName, x, y, r1, r2, alpha, fineness, i)
num = 0
while num <= 2*math.pi do
ui.addTextArea(i, "", playerName, r1*math.cos(num)+x-r2/2, r1*math.sin(num)+y-r2/2, r2, r2, 0x000000, 0x000001, alpha, true)
num = num + 2*math.pi/fineness
if i then
i = i + 1
end
end
return i
end

nightMode = function(playerName)
i = 0
x = 400
y = 250

i = createRing(playerName, x, y, 90, 35, 0.5, 25, i)
i = createRing(playerName, x, y, 120, 40, 0.66, 30, i)
i = createRing(playerName, x, y, 160, 50, 0.83, 40, i)

ui.addTextArea(i, "", playerName, 545, 0, 255, 400, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 0, 255, 400, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 0, 800, 123, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 375, 800, 25, 0x000000, 0x000001, 1, true)
i=i+1
end

eventNewPlayer = function(playerName)
nightMode(playerName)
tfm.exec.respawnPlayer(playerName)
end

for k, v in next, tfm.get.room.playerList do
eventNewPlayer(v.playerName)
end


Here's a small minigame that I created that uses the Night Mode function (duck to collect the ?s, may crash tho for unknown reasons from time to time). This is just an example of what you can do with this:

Minigame

Minigame Pastebin
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
-- settings
tfm.exec.disableAutoTimeLeft(disable)
tfm.exec.disableAfkDeath(disable)
tfm.exec.disableAllShamanSkills(disable)
tfm.exec.disableAutoScore(disable)
tfm.exec.disableAutoNewGame(disable)
tfm.exec.disableMortCommand(disable)
tfm.exec.disableAutoShaman(disable)
initialMap = "@7640468"
tfm.exec.newGame(initialMap)
roundStart = false

-- constants
playerData = {}

-- functions
findIndex = function(value, array)
rArray = {}
for i=1, #array do
rArray[array[i]] = i
end
return rArray[value]
end

pythag = function(x1,y1,x2,y2,range)
return ((x1 - x2)^2 + (y1 - y2)^2 < range^2)
end

generateCollectables = function(playerName)
for i=1,4 do
local randInt = math.random(1, #spawners.x)
local index = #playerData[playerName].collectables.x
playerData[playerName].collectables.x[index+1] = spawners.x[randInt]
playerData[playerName].collectables.y[index+1] = spawners.y[randInt]
end
end

spawnCollectables = function(playerName)
for i=1, #playerData[playerName].collectables.x do
ui.addTextArea(500 + i-1, "?", playerName, playerData[playerName].collectables.x[i]-5, playerData[playerName].collectables.y[i]-5, 20, 20, 0x000000, 0x000001, 0, false)
end
end

createRing = function(playerName, x, y, r1, r2, alpha, fineness, i)
num = 0
while num <= 2*math.pi do
ui.addTextArea(i, "", playerName, r1*math.cos(num)+x-r2/2, r1*math.sin(num)+y-r2/2, r2, r2, 0x000000, 0x000001, alpha, true)
num = num + 2*math.pi/fineness
if i then
i = i + 1
end
end
return i
end

nightMode = function(playerName)
i = 0
x = 400
y = 250

i = createRing(playerName, x, y, 90, 35, 0.5, 25, i)
i = createRing(playerName, x, y, 120, 40, 0.66, 30, i)
i = createRing(playerName, x, y, 160, 50, 0.83, 40, i)

ui.addTextArea(i, "", playerName, 545, 0, 255, 400, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 0, 255, 400, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 0, 800, 123, 0x000000, 0x000001, 1, true)
i=i+1
ui.addTextArea(i, "", playerName, 0, 375, 800, 25, 0x000000, 0x000001, 1, true)
i=i+1
end



-- events
eventNewPlayer = function(playerName)
if not playerData[playerName] then
playerData[playerName] = {collectables = {x = {}, y = {}}}
end
tfm.exec.bindKeyboard(playerName, 40, true, true)
tfm.exec.bindKeyboard(playerName, 83, true, true)
nightMode(playerName)
tfm.exec.setPlayerScore(playerName, 0, false)
end

eventNewGame = function()
local xml = (tfm.get.room.xmlMapInfo.xml or '<C><P /><Z><S /><D /><O /></Z></C>')
spawners = {x = {},y = {}}
if xml:find('<O') then -- creds to Ratufufu for finding the x and ys of the yellow nails
for data in xml:gmatch('<O(.-)/>') do
if data:find('C="22"') then
spawners.x[#spawners.x + 1] = (tonumber(data:match('X="(.-)"')) or 0)
spawners.y[#spawners.x + 1] = (tonumber(data:match('Y="(.-)"')) or 0)
end
end
end
for k, v in next, tfm.get.room.playerList do
generateCollectables(v.playerName)
spawnCollectables(v.playerName)
tfm.exec.respawnPlayer(v.playerName)
end
roundStart = true
end

eventKeyboard = function(playerName, keyCode, down)
if keyCode == 40 or keyCode == 83 then
for i=1, #playerData[playerName].collectables.x do
if pythag(playerData[playerName].collectables.x[i], playerData[playerName].collectables.y[i], tfm.get.room.playerList[playerName].x, tfm.get.room.playerList[playerName].y, 40) then
local randInt = math.random(1, #spawners.x)
print(spawners.x[randInt] .. "," .. spawners.y[#spawners.x])
playerData[playerName].collectables.x[i] = spawners.x[randInt]
playerData[playerName].collectables.y[i] = spawners.y[randInt]
print(randInt)
ui.addTextArea(500 + i-1, "?", playerName, spawners.x[randInt]-5, spawners.y[randInt]-5, 20, 20, 0x000000, 0x000001, 0, false)
tfm.exec.setPlayerScore(playerName, 1, true)
end
end
end
end

-- execution
for k, v in next, tfm.get.room.playerList do
eventNewPlayer(v.playerName)
end


Unfortunately, this comes with some weird map constraints (A huge disadvantage to the usefulness of this code). Basically just don't move the purple background rectangles within the xml template, and only create grounds within those rectangles, and this will allow the module to work. (I don't expect anyone to actually create a map off of this template either, but just putting it out there in case anyone actually wants to)

Xml Template

Night Mode Pastebin
a dit :
<C><P L="1600" H="800" /><Z><S><S X="200" o="324650" L="400" Y="400" H="800" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S X="800" o="324650" L="1600" Y="733" H="135" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S X="1400" o="324650" L="400" Y="400" H="800" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S X="800" o="324650" L="1600" Y="125" H="250" P="0,0,0.3,0.2,0,0,0,0" T="12" /></S><D><DS X="802" Y="473" /></D><O /></Z></C>



To run all of this code, copy (using Pastebin or here), go to your tribehouse, /lua, paste. (prob pretty obvious for most of you tho)

Dernière modification le 1567558500000
Radioactium
« Citoyen »
1567554960000
    • Radioactium#0000
    • Profil
    • Derniers messages
    • Tribu
#2
  0
(removed)

Dernière modification le 1567558560000
Radioactium
« Citoyen »
1567556040000
    • Radioactium#0000
    • Profil
    • Derniers messages
    • Tribu
#3
  0
(also removed)

Dernière modification le 1567558560000
Noooooooorr
« Censeur »
1567860900000
    • Noooooooorr#0000
    • Profil
    • Derniers messages
#4
  0
Nice!!
Wtal
« Citoyen »
1569504480000
    • Wtal#5272
    • Profil
    • Derniers messages
    • Tribu
#5
  0
Great work!
Grth_demon
« Citoyen »
1688433180000
    • Grth_demon#2154
    • Profil
    • Derniers messages
    • Tribu
#6
  0
I like it :D
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [Script] Nightmode
© Atelier801 2018

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

Version 1.27