lua-hill
v3.0.2
Published
Converts lua to Node-Hill
Downloads
5
Readme
Lua-Hill
How to run
Download the lua-hill-server.zip.
Open your folder in the file explorer, and in the top bar type "cmd" and press enter.
Type
npm i lua-hill@latest
Enter the
user_scripts
folder and openmain.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:
exec.command(cmd, function(caller,args)
end)
Example:
module.main = function()
exec.command("kill", function(plr,msg)
plr.kill()
end)
end
module.main = function()
exec.command("msg", function(plr,args)
print(plr.username.. " said: "..args.."!")
end)
end
module.join
Inside the module.join function is where all the code gets executed when a new player joins the server. It takes one argument, the player who joined.
module.join = function(plr)
plr.setSpeed(10)
plr.setJumpPower(10)
plr.topPrint("Welcome to the server "..plr.username.."!")
end
module.leave
Inside the module.leave function is where all the code gets executed when a player leaves the server. It takes one argument, the player who left.
module.leave = function(plr)
Game.topPrintAll(plr.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
Game.loadBrk(location) -- No further code needed
All text-based Game functions -- centerPrint, topPrint, bottomPrint, etc. -- are, by default, 3 seconds long.
Player
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:
local v = Vector3.make(x,y,z)
Default values for x,y,z are 1.
Vector methods are temporarily disabled.
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()
local bot = Instance.create("Bot")
bot.Outfit({
face = "420",
hat1 = "42599",
torso = "#00ff00",
leftLeg = "#0a1b32",
rightLeg = "#0a1b32"
})
end
module.join = function(plr)
plr.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()
local balloon = Instance.create("Tool","balloon") -- tool not Tool
balloon.model(216)
balloon.activated(function(plr)
Game.topPrintAll(plr.username.." just clicked with the balloon!")
end)
balloon.equipped(function(plr)
plr.setJumpPower(10)
end)
balloon.unequipped(function(plr)
plr.setJumpPower(5)
end)
end
Tools have a different syntax:
Tool.model(id)
Tool.enabled(boolean)
Tool.name(str)
Tool.tooldId(id)
Tool.equipped(cb(plr))
Tool.unequipped(cb(plr))
Tool.activated(cb(plr))
Teams
To create a team:
local team = Instance.create("Team", name, color)
Example:
local Gamers = Instance.create("Team", "Gamers", "#ff0000")
Bots
To create a bot:
local bot = Instance.create("Bot", name)
Bot example:
module.main = function()
local bot = Instance.create("Bot", "Vibe checker")
local pos = Vector3.make(10,10,0)
local size = Vector3.make(3,3,3)
bot.Outfit({
face = "83758"
})
bot.setSpeech("Vibes")
bot.setPosition(pos)
bot.setScale(size)
bot.moveTowardsPlayer(100,"Vibes",0)
end
Modified bot methods
Bot.moveTowardsPlayer(radius, speech, speed)
Bricks
To create a new brick:
local b = Instance.create("Brick", pos, scale, color)
Example brick:
local debounce = true
module.main = function()
local b = Instance.create("Brick", Vector3.make(), Vector3.make(5,5,5), "#ff0000")
b.touching(function(plr)
if debounce then
debounce = false
b.setColor("#00ff00")
plr.message("You stepped [#00ff00]on [#ffffff]the brick!")
end
end)
b.touchingEnded(function(plr)
debounce = true
b.setColor("#ff0000")
plr.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
exec.findPlayer(val,prop)
-- returns if a player is found with valid properties of a player. Example:
local cheats = findPlayer("cheats") -- Default property is username
cheats.kill()
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}