アットウィキロゴ

Lua作品集


作品1:スコア設定

 書式:!score [引数1] [引数2]
 [引数1]:スコア.
 [引数2]:addで現在スコアに[引数1]を加算,記入無しでスコアを[引数2]に.
 例:!score 100 add, !score 80

 

<コード>

function eventChatCommand(playerName,command)
   
local args = {}
    for arg in command:gmatch("[^%s]+") do
       table.insert(args,arg:lower())
    end
    if args[1] == "score" then
        if args[3] == "add" then
            t = true
        else
            t = false
       end
       tfm.exec.setPlayerScore(playerName, args[2], t)
    end
end

 

作品2:召喚回数制限

 部屋に入った人は全員シャーマンになる.風船を3回召喚すると死ぬ.

<コード>

players = {}

function eventLoop(time,remaining,queue)
    for name,Name in pairs(tfm.get.room.playerList) do
        if not Name.isShaman then
            tfm.exec.setShaman(name)
            players[name] = {

                name = name,
                balloon = 0,
                score = 0
            }
        end
    end
end

function eventSummoningEnd(playerName, objectType, xPosition, yPosition, angle, xSpeed, ySpeed, other)
    if objectType == 28 then
        players[playerName].balloon = players[playerName].balloon + 1
    end
    if players[playerName].balloon == 3 then
       
tfm.exec.killPlayer(playerName)
    end
end

 

作品3:接触死亡

 部屋に入った人は全員シャーマンになる.実体の風船に触れると死亡.

<コード>

function eventLoop(time,remaining,queue)
    for name,Name in pairs(tfm.get.room.playerList) do
        if not Name.isShaman then
            tfm.exec.setShaman(name)
        end
    end
    for object, Object in pairs(tfm.get.room.objectList) do
        if Object.type == 28 and Object.ghost == false then
            for name, Name in pairs(tfm.get.room.playerList) do
                squarelength = (Object.x - Name.x)^2 + (Object.y - Name.y)^2
                if squarelength <= 1000 then
                    tfm.exec.killPlayer(name)
                end
            end
        end
    end
end

最終更新:2015年08月20日 07:55