2.0.2 • Published 4 years ago

brickhill-server v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Lua-Hill

Discord | npm

How to run

  1. Download the lua-hill-server.zip.

  2. Open your folder in the file explorer, and in the top bar type "cmd" and press enter.

  3. Type npm i lua-hill@latest

  4. Enter the user_scripts folder and open main.lua. main.lua is where all your code should be in.

module.main

Inside the module.main function is where all the code is executed as if you were coding in a normal JavaScript file. This function takes no arguments.

Commands

Commands are created by calling exec.command(cmd,cb). Once you are in the callback function, player becomes a global variable representing the player who called the command.

module.main = function()
    exec.command("kill", function()
        player.kill()
    end)
end

To get the player's message post-command use the variable: command.message.

module.main = function()
    exec.command("msg", function()
        print(player.username.. " said: "..command.message.."!")
    end)
end

module.join

Inside the module.join function is where all the code gets executed when a new player joins the server. player becomes a global variable representing the player who just joined the server.

module.join = function()
    player.setSpeed(10)
    player.setJumpPower(10)
    player.topPrint("Welcome to the server "..player.username.."!")
end

module.leave

Inside the module.leave function is where all the code gets executed when a player leaves the server. player becomes a global variable representing the player who just left the server.

module.leave = function()
    Game.topPrintAll(player.username.." just left!")
end

Game

Game has all the normal functions, properties, and syntax as in Node-Hill, and is a global variable.

Game syntax exceptions

Game.setMOTD("Welcome gamers!")
Game.players("username")
-- Expected output:
-- Player1,Player2,Player3

Game._local -- Equivalent to Game.local

All text-based Game functions -- centerPrint, topPrint, bottomPrint, etc. -- are, by default, 3 seconds long.

Player

player is used as a global variable while in funtions (exec.command, module.join, module.leave, etc.). player has all the normal functions, properties, and syntax as in Node-Hill.

Player differences and syntax exceptions

player.heal(amt) -- Heals player by amt
player.damage(amt) -- Damages player by amt

-- Returns all following properties as strings (see globals to see how to get these in lua tables)
player.cameraPosition()
player.cameraRotation()
player.position()
player.scale()
player.assets()
player.colors()

-- Events
player.click(cb)
player.chatted(cb)
player.died(cb)
player.keyPress(cb)
-- Once keypress is emitted, `event.key` returns the key pressed
player.respawn(cb)

initialSpawn and avatarLoaded are not in Lua-Hill since the code in module.join is nested in an initialSpawn function.

Vector3

Create a Vector3 by typing:

Vector3.make(x,y,z)

Default values for x,y,z are 1.

Once a Vector3 object is created, the keyword Vector becomes a global variable.

Vector3.make(2,1,5)

Vector.add(3,2,5)
-- Expected output:
-- {"x": 5, "y": 3, "z": 10}

Vector3.make(4,2,0)

Vector.multiply(2,1,4)
-- Expected output
-- {"x": 8, "y": 2, "z": 0}

Vector has all the same functions as Vector3 in Node-Hill.

Outfits

To create a player/bot outfit, call the Outfit method on either and add a table for the argument. The keys of the table should be the outfit property that is being changed and the value is the value corresponding to the key (values should be a hex value or an id).

Important: every value has to be a string.

player.Outfit({
    prop: value
})
Bot.Outfit({
    prop: value
})

Example:

module.main = function()
    Instance.create("Bot")
    Bot.Outfit({
        face = "420",
        hat1 = "42599",
        torso = "#00ff00",
        leftLeg = "#0a1b32",
        rightLeg = "#0a1b32"
    })
end

module.join = function()
    player.Outfit({
        face = "420",
        hat1 = "42599",
        torso = "#00ff00"
    })
end

Important: Outfits get set automatically.

Instance.create()

Call this function to create a new instance. Instance types: Tool, Bot, Brick, Team

Instance.create("Tool", name)
Instance.create("Bot", name)
Instance.create("Brick", position, scale, color)
Instance.create("Team", name, color)

Important: After specifying the instance being created, every argument after is optional.

Tools

Balloon tool example:

module.join = function()
    Instance.create("Tool","balloon") -- tool not Tool

    Tool.model(216)

    Tool.activated(function()
        Game.topPrintAll(player.username.." just clicked with the balloon!")
    end)
    Tool.equipped(function()
        player.setJumpPower(10)
    end)
    Tool.unequipped(function()
        player.setJumpPower(5)
    end)
end

Once Instance.create("Tool", name) is called, Tool becomes a global variable. Tools have a different syntax:

Tool.model(id)
Tool.enabled(boolean)
Tool.name(str)
Tool.tooldId(id)
Tool.equipped(cb)
Tool.unequipped(cb)
Tool.activated(cb)

Teams

To create a team:

Instance.create("Team", name, color)

Example:

Instance.create("Team", "Gamers", "#ff0000")

Bots

To create a bot:

Instance.create("Bot", name)

Once Instance.create("Bot") is called, Bot becomes a global variable with all possible methods as in Node-Hill. Bot example:

module.main = function()
    Instance.create("Bot", "Vibe checker")

    Bot.Outfit()
    Outfit.face(83758)
    Outfit.set()

    Bot.setSpeech("Vibes")
    Bot.setPosition(Vector3.make(10,10,0))
    Bot.setScale(Vector3.make(3,3,3))
    Bot.moveTowardsPlayer(100,"Vibes",0)
end

Modified bot methods

Bot.moveTowardsPlayer(radius, speech, speed)

Bricks

To create a new brick:

Instance.create("Brick", pos, scale, color)

Once Instance.create("Brick") is called, Bot becomes a global variable with all possible methods as in Node-Hill. Example brick:

local debounce = true

module.main = function()

Instance.create("Brick", Vector3.make(), Vector3.make(5,5,5), "#ff0000")

    Brick.touching(function()
        if debounce then
            debounce = false
            Brick.setColor("#00ff00")
            player.message("You stepped [#00ff00]on [#ffffff]the brick!")
        end
    end)

    Brick.touchingEnded(function()
        debounce = true
        Brick.setColor("#ff0000")
        player.message("You stepped [#ff0000]off [#ffffff]the brick!")
    end)

end

Misc

List of misc commands:

exec.loop(cb,time)
-- Repeatedly calls the function `cb` every 100ms by default
-- Time is in ms

Globals

Globals are temporarily disabled

List of global variables:

globals.getPosition(player)
globals.getCameraPosition(player)
globals.getCameraRotation(player)
globals.getScale(player)
globals.getAssets(player)
globals.getPlayers(getPlayersOption) -- options include all valid player properties (e.g. username, userId, etc.)
globals.getColors(player)

globals.getPlayers(option)

globals.getPlayers(option) takes an argument, option, to specify how to list each player in the game. The argument taken is any valid property of player, check properties from the Node-Hill documentations.

print(globals.getPlayers("username"))
-- Expected output:
-- {cheats, Spotwich, Dragonian, Prevent}

print(globals.getPlayers("userId"))
-- Expected output:
-- {127118, 86632, 2760, 799}
2.0.2

4 years ago