×

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
  • /
  • [LUA] Обсуждение и вопросы только здесь
« ‹ 4 / 12 › »
[LUA] Обсуждение и вопросы только здесь
Exlferq
« Citoyen »
1382518140000
    • Exlferq#0000
    • Profil
    • Derniers messages
    • Tribu
#61
  0
Clowfish a dit :
Обычно этой функцией начинают свою быдло игру:
function main()

Причем это необязательно, но вы это делаете.
Bushmeister
« Consul »
1382547960000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#62
  0
Exlferq a dit :
Причем это необязательно, но вы это делаете.

lol, а польза от этого есть?
Exlferq
« Citoyen »
1382596080000
    • Exlferq#0000
    • Profil
    • Derniers messages
    • Tribu
#63
  0
Bushmeister a dit :
lol, а польза от этого есть?

Нет.
Bushmeister
« Consul »
1382627160000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#64
  0
sc a dit :
keyCodeUserName = {}
keyCodeULastTime = {}
for pName,player in pairs(tfm.get.room.playerList) do
tfm.exec.bindKeyboard(pName, 37, true, true)
tfm.exec.bindKeyboard(pName, 38, true, true)
tfm.exec.bindKeyboard(pName, 39, true, true)
tfm.exec.bindKeyboard(pName, 40, true, true)
keyCodeULastTime[pName] = os.time()
keyCodeUserName[pName] = 20
end
function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
if keyCode == 37 then
keyCodeUserName[playerName] = 20
elseif keyCode == 39 then
keyCodeUserName[playerName] = 19
elseif keyCode == 40 then
if os.time() - keyCodeULastTime[playerName] >= 1000 then
tfm.exec.addShamanObject(keyCodeUserName[playerName], xPosition, yPosition + 15, 0, 0, 0, false)
keyCodeULastTime[playerName] = os.time()
end
end
end

Как сделать так, чтобы ядро мог спавнить только шаман, а не все игроки?
Timatimaaa
« Citoyen »
1382630400000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#65
  0
Bushmeister a dit :
Как сделать так, чтобы ядро мог спавнить только шаман, а не все игроки?

Скрипт a dit :

keyCodeUserName = {}
keyCodeULastTime = {}
for pName,player in pairs(tfm.get.room.playerList) do
tfm.exec.bindKeyboard(pName, 37, true, true)
tfm.exec.bindKeyboard(pName, 38, true, true)
tfm.exec.bindKeyboard(pName, 39, true, true)
tfm.exec.bindKeyboard(pName, 40, true, true)
keyCodeULastTime[pName] = os.time()
keyCodeUserName[pName] = 20
end
function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
if tfm.get.room.playerList[playerName].isShaman then
if keyCode == 37 then
keyCodeUserName[playerName] = 20
elseif keyCode == 39 then
keyCodeUserName[playerName] = 19
elseif keyCode == 40 then
if os.time() - keyCodeULastTime[playerName] >= 1000 then
tfm.exec.addShamanObject(keyCodeUserName[playerName], xPosition, yPosition + 15, 0, 0, 0, false)
keyCodeULastTime[playerName] = os.time()
end
end
end
end

Так?
Bushmeister
« Consul »
1382630520000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#66
  0
Timatimaaa a dit :
Так?

Омг, все варианты перепробовал а про этот забыл...
Спасибо!
upd
Пример не работает

if eventPlayerGetCheese(playerName)
tfm.exec.chatMessage("А теперь принеси сыр к нам, иначе заложник умрёт!", playerName)
end

[•] Init Error : transformice.lua:3: [string "transformice.lua"]:2: 'then' expected


если добавить then


[•] Init Error : transformice.lua:1: attempt to call nil
Timatimaaa
« Citoyen »
1382712540000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#67
  0
Bushmeister a dit :

Пример не работает

if eventPlayerGetCheese(playerName)
tfm.exec.chatMessage("А теперь принеси сыр к нам, иначе заложник умрёт!", playerName)
end

[•] Init Error : transformice.lua:3: [string "transformice.lua"]:2: 'then' expected


если добавить then


[•] Init Error : transformice.lua:1: attempt to call nil

function eventPlayerGetCheese(playerName)
tfm.exec.chatMessage("А теперь принеси сыр к нам, иначе заложник умрёт!", playerName)
end
Bushmeister
« Consul »
1382955600000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#68
  0
Timatimaaa a dit :
function eventPlayerGetCheese(playerName)
tfm.exec.chatMessage("А теперь принеси сыр к нам, иначе заложник умрёт!", playerName)
end

ty
У меня одного так?

http://i.imgur.com/83jYamM.png
UPD: заработало!!1
Что то не врубаюсь с tfm.get...
Можно ли к этому скрипту пример?

http://i.imgur.com/h0Xavkq.png
Timatimaaa
« Citoyen »
1382969160000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#69
  0
Bushmeister a dit :

Можно ли к этому скрипту пример?

Скрипт a dit :

sec = -100500
function eventChatCommand(name, command)
if tfm.get.room.xmlMapInfo then
perm = tfm.get.room.xmlMapInfo.permCode
kod = tfm.get.room.xmlMapInfo.mapCode
avtor = tfm.get.room.xmlMapInfo.author
if command == "код" then
ui.addTextArea(1, "Код: <font color='#FF0000'>@"..kod.."</font>", playername, 5, 375, 170, 16, 0x324650, 0x324650, 1f)
sec = 5
sec = sec*2
elseif command == "автор" then
ui.addTextArea(1, "Автор: <font color='#FFF000'>"..avtor.."</font>", playername, 5, 375, 170, 16, 0x324650, 0x324650, 1f)
sec = 5
sec = sec*2
elseif command == "перм" then
ui.addTextArea(1, "Перманет статус: <font color='#FF0000'>P"..perm.."</font>", playername, 5, 375, 170, 16, 0x324650, 0x324650, 1f)
sec = 5
sec = sec*2
elseif command == "всё сразу" then
ui.addTextArea(1, "Код: <font color='#FF0000'>@"..kod.."</font> | Автор: <font color='#FFF000'>"..avtor.."</font> | Перманет статус: <font color='#FF0000'>P"..perm.."</font>", playername, 5, 375, 470, 16, 0x324650, 0x324650, 1f)
sec = 10
sec = sec*2
end
end
end

function eventLoop()
sec = sec - 2
if sec == 0 then
for name,player in pairs(tfm.get.room.playerList) do
ui.removeTextArea(1, name)
end
end
end

Команды:
!всё сразу
!автор
!код
!перм

С хмл у меня не получилось ._.
Bushmeister
« Consul »
1383141120000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#70
  0
Почему-то не работает...
Timatimaaa
« Citoyen »
1383152340000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#71
  0
Bushmeister a dit :
Почему-то не работает...

После включения скрипта поставь какую-нибудь карту, после этого команды будут работать.
P.S. На ванилла картах не работает.
Bushmeister
« Consul »
1383155160000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#72
  0
Классно, спасибо.
Другой вопрос...
Можно ли у каждого игрока сделать "личную" переменную?
То есть, если игрок выполнил условие, то прибавлялось +1(i+1), но именно к "его" переменной, а у того кто не выполнил так и остается 0 (i=0).
Timatimaaa
« Citoyen »
1383158880000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#73
  0
Bushmeister a dit :
Классно, спасибо.
Другой вопрос...
Можно ли у каждого игрока сделать "личную" переменную?
То есть, если игрок выполнил условие, то прибавлялось +1(i+1), но именно к "его" переменной, а у того кто не выполнил так и остается 0 (i=0).

Скрипт a dit :

i = {}
for name, player in pairs(tfm.get.room.playerList) do
i[name] = 0
end
function eventPlayerWon(namep)
i[namep] = i[namep] +1;
end

Условие - Войти в нору (например)
i - Переменная

Если хочешь вывести переменную для определённого игрока то
Скрипт a dit :

print (i["Bushmeister"])
print (i["Timatimaaa"])

(Например)

Так?
P.S. Чувствую что где-то что-то упустил ._.
Bushmeister
« Consul »
1383223500000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#74
  0
Timatimaaa a dit :
Условие - Войти в нору (например)
i - Переменная

Если хочешь вывести переменную для определённого игрока то

(Например)

Так?
P.S. Чувствую что где-то что-то упустил ._.

Все хорошо работает, спасибо!
Что то не могу понять, как использовать cmd:sub(колвопроверяемыхсимволов) так, чтобы если номер карты был @такойто то например print("lol").Если код другой, то соответственно не выполняется команда.
===
И да, проблема есть, вроде все забиндено, указно, но не работает...

q a dit :
function eventNewGame()
for pName,player in pairs(tfm.get.room.playerList) do
tfm.exec.bindKeyboard(pName, 37, true, true)
tfm.exec.bindKeyboard(pName, 38, true, true)
tfm.exec.bindKeyboard(pName, 39, true, true)
tfm.exec.bindKeyboard(pName, 40, true, true)
tfm.exec.bindKeyboard(pName, 65, true, true)
tfm.exec.bindKeyboard(pName, 68, true, true)
tfm.exec.bindKeyboard(pName, 83, true, true)
tfm.exec.bindKeyboard(pName, 87, true, true)
keyCodeULastTime[pName] = os.time()
keyCodeUserName[pName] = 20
end
end
keyCodeUserName = {}
keyCodeULastTime = {}
function eventKeyboard(playerName, keyCode, down, xPosition, yPosition)
if tfm.get.room.playerList[playerName].isShaman then
if keyCode == 65 then
keyCodeUserName[playerName] = 20
elseif keyCode == 37 then
keyCodeUserName[playerName] = 20
elseif keyCode == 39 then
keyCodeUserName[playerName] = 19
elseif keyCode == 68 then
keyCodeUserName[playerName] = 19
elseif keyCode == 40 or keyCode == 83 then
if os.time() - keyCodeULastTime[playerName] >= 1000 then
tfm.exec.addShamanObject(keyCodeUserName[playerName], xPosition, yPosition + 15, 0, 0, 0, false)
keyCodeULastTime[playerName] = os.time()
end
end
end
end

Не меняет объект при нажатии клавишы A (65) на 20 (ядро влево), но все остальные клавишы работают.
Timatimaaa
« Citoyen »
1383230820000
    • Timatimaaa#0000
    • Profil
    • Derniers messages
    • Tribu
#75
  0
Bushmeister a dit :
Все хорошо работает, спасибо!
Что то не могу понять, как использовать cmd:sub(колвопроверяемыхсимволов) так, чтобы если номер карты был @такойто то например print("lol").Если код другой, то соответственно не выполняется команда.

Скрипт a dit :

function eventChatCommand(name, cmd)
if cmd:sub(0,2) == "np" then
if cmd:sub(4) == "@kod" then
print("lol")
end
end
end

Если !np @kod то print("lol")


Bushmeister a dit :
И да, проблема есть, вроде все забиндено, указно, но не работает...
Не меняет объект при нажатии клавишы A (65) на 20 (ядро влево), но все остальные клавишы работают.

У меня тоже именно A (65) не работает.
UPD
Тиг лол.
А = 81
W = 90
S = 83
D = 68
Пришлось все номера перепробовать
Bushmeister
« Consul »
1383392880000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#76
  0
Timatimaaa a dit :
Если !np @kod то print("lol")

У меня тоже именно A (65) не работает.
UPD
Тиг лол.
А = 81
W = 90
S = 83
D = 68
Пришлось все номера перепробовать

Тиг лол[2]
на ен форуме узнал что 65 = Q а 81 = A, хотя должно быть наоборот, да и видимо это не только с этими кодами беда...
↓
Timatimaaa a dit :
W = 90

APD
eventFileLoaded(fileName)
То есть, я могу загрузить на некий сервер lua файл и он сможет его прочитать и выполнить функции?
Upd2:
й a dit :
function eventSumminingCancel(playerName)
tfm.exec.chatMessage("Какой перерыв? Строй предмет давай!", PlayerName)
end

в примерах ошибки : eventSummOning а не i/
============
qq a dit :
function eventSummoningEnd(playerName,0)
print("Ура, постройка была закончена!", PlayerName)
end

Указывая тип (0(стрелка)) происходит какая-то ошибка:
q a dit :
[13:25] [•] Init Error : transformice.lua:756: [string "transformice.lua"]:1: or '...' expected

=
не могу понять с чем связано.
Exlferq
« Citoyen »
1383568200000
    • Exlferq#0000
    • Profil
    • Derniers messages
    • Tribu
#77
  0
Загрузить без прав ничего нельзя, а так - да. Можешь список карт в файлике хранить.
>>
print("Ура, постройка была закончена!", PlayerName)
Изменить на chatMessage
Bushmeister
« Consul »
1383575760000
    • Bushmeister#0000
    • Profil
    • Derniers messages
    • Tribu
#78
  0
Exlferq a dit :
Загрузить без прав ничего нельзя, а так - да. Можешь список карт в файлике хранить.
&gt;&gt;
print("Ура, постройка была закончена!", PlayerName)
Изменить на chatMessage

Тоже самое...
Exlferq
« Citoyen »
1383655800000
    • Exlferq#0000
    • Profil
    • Derniers messages
    • Tribu
#79
  0
Bushmeister a dit :
Тоже самое...

А, сори затупил. Там функция принимает не 2 переменные
Smgxxx
1383745020000
    • Smgxxx#0000
    • Profil
    • Derniers messages
    • Tribu
#80
[Modéré par Denezhki]
  • Forums
  • /
  • Transformice
  • /
  • Modules
  • /
  • [LUA] Обсуждение и вопросы только здесь
« ‹ 4 / 12 › »
© Atelier801 2018

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

Version 1.27