Skip to content

Commit 0982f5b

Browse files
committed
.
1 parent cd8148f commit 0982f5b

File tree

9 files changed

+187
-52
lines changed

9 files changed

+187
-52
lines changed

docs/intro.md

+1-38
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,5 @@
22
sidebar_position: 1
33
---
44

5-
# Basics of scripting in ROBLOX Studio and TRIA.os
5+
# Intro
66

7-
Welcome to the scripting documentation of TRIA.os!<br></br>
8-
By default we assume you have some knowledge of general scripting in ROBLOX Studio so the documents will sound a bit nerdy, but if you don't have the neccessary information, you can consult this page.
9-
10-
## Booleans
11-
12-
Boolean is an easy-to-understand data type which one has two values: `true` or `false`. Think of it like a light switch, there are only two states a light bulb can be which is on or off.<br></br>
13-
In [conditional statements](https://create.roblox.com/docs/scripting/luau/control-structures#if-statements), if a boolean isn't `false` or `nil`, Luau (the scripting language used for Studio) will assume the boolean as `true`.<br></br>
14-
15-
## Strings
16-
17-
String is a data type used to store text data, such as letters, numbers and symbols.<br></br>
18-
To declare a string, type out anything you want and then wrap that thing in double quotes (`"`) or single quotes (`'`).<br></br>
19-
`Example:`<br></br>
20-
```lua
21-
message = "Hello world!"
22-
```
23-
Combining (or concatenating) strings is quite simple, add two periods (`..`) between those strings. Concatenating strings won't insert a space between them so you'll have to put one yourself at the end of the first string and beginning of the next string or concatenate a space (`" "`) between the strings.<br></br>
24-
`Example:`<br></br>
25-
```lua
26-
message1 = "Hello"
27-
message2 = "world!"
28-
message2WithSpaceAtTheBeginning = " world!"
29-
print(message1 .. " " .. message2) -- Hello world!
30-
print(message1 .. message2WithSpaceAtTheBeginning) -- Hello world!
31-
print(message1 .. message2) -- Helloworld! (this is not a typo)
32-
```
33-
34-
## Tables
35-
36-
Tables are used to store multiple types of data that isn't `nil` (which is nothing) such as booleans, numbers, strings, functions,...<br></br>
37-
You can declare a table by curly braces (`{}`).
38-
`Example:`<br></br>
39-
```lua
40-
table1 = {} -- creates an empty table
41-
print(table1) -- {}
42-
```
43-
Tables can be used as arrays or dictionaries. Arrays use numbered lists for indexing data; dictionaries can have numbers, strings, objects as indices.

moonwave.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ classes = ["MapLib"]
1515

1616
[[classOrder]]
1717
section = "Features"
18-
classes = ["Skills", "PlayerUI", "Settings", "Players", "Cleanup", "Teleport"]
18+
classes = ["Skills", "PlayerUI", "Settings", "Players", "Cleanup", "Teleport", "Lighting"]
1919

2020
[[classOrder]]
2121
section = "Miscellaneous"

src/Features/Lighting.lua

+70-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LightingFeature.__index = LightingFeature
1717
local remote = ReplicatedStorage.Remotes.Features.ChangeLighting
1818

1919
--- @class Lighting
20-
--- This is a MapLib Feature. It can be accessed by `MapLib:GetFeature("LightingFeature")`.
20+
--- This is a MapLib Feature. It can be accessed by `MapLib:GetFeature("Lighting")`.
2121

2222
function LightingFeature.new(MapLib)
2323
local self = setmetatable({}, LightingFeature)
@@ -31,7 +31,74 @@ function LightingFeature.new(MapLib)
3131
return self
3232
end
3333

34-
--- This function is used to toggle the sliding function on or off.
34+
--[=[
35+
@within Lighting
36+
@method SetLighting
37+
@since 0.11
38+
@param properties { [string]: any }
39+
@param postEffects { [string]: { [string]: any } }
40+
41+
This function can to be used to change the lighting of a map mid round. We discourage usage of changing lighting
42+
with `game.Lighting[Property] = value` cause it doesnt replicate for spectators.
43+
44+
**Example:**
45+
```lua
46+
-- Changes the fog to 100 and the fog color to white
47+
local LightingFeature = Maplib:GetFeature("Lighting")
48+
49+
LightingFeature:SetLighting({
50+
FogEnd = 100,
51+
FogColor = Color3.fromRGB(255, 255, 255)
52+
})
53+
```
54+
55+
:::info
56+
This function also supports lighting effects to be updated and they will be replicated to specators.
57+
```lua
58+
-- Changes the fog to 100 and the fog color to white and makes everything monochrome.
59+
local LightingFeature = Maplib:GetFeature("Lighting")
60+
61+
LightingFeature:SetLighting({
62+
FogEnd = 100,
63+
FogColor = Color3.fromRGB(255, 255, 255)
64+
}, {
65+
ColorCorrection = {
66+
Saturation = -1,
67+
},
68+
})
69+
```
70+
71+
:::
72+
:::caution
73+
For the game to be able to edit post effects they have to be correctly placed inside the lighting folder inside settings.
74+
If they are created in a script the game will not see these and refuse to update the lighting properties.
75+
:::
76+
77+
:::tip
78+
Since atmosphere instances don't have any enabled or disabled property we can get around that by parenting the instance to ReplicatedStorage
79+
and then we can parent it back to lighting when we need it.
80+
81+
```lua
82+
local LightingFeature = Maplib:GetFeature("Lighting")
83+
84+
--Disables the atmosphere effect
85+
LightingFeature:SetLighting({}, {
86+
Atmosphere = {
87+
Parent = game.ReplicateStorage,
88+
},
89+
})
90+
91+
task.wait(5)
92+
--Enables the atmosphere effect
93+
LightingFeature:SetLighting({}, {
94+
Atmosphere = {
95+
Parent = game.Lighting,
96+
},
97+
})
98+
```
99+
:::
100+
]=]
101+
35102
function LightingFeature:SetLighting(properties: { [string]: any }, postEffects: { [string]: { [string]: any } })
36103
if RunService:IsClient() then
37104
for property, value in pairs(properties) do
@@ -67,4 +134,5 @@ if RunService:IsServer() then
67134
end)
68135
end
69136

137+
70138
return LightingFeature

src/Features/PlayerUI.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ end
4040
@method LoadUI
4141
@since 0.11
4242
@client
43-
--@param gui ScreenGui
44-
This function is used to load a `ScreenGui` from the map into the players PlayerGUI.
43+
@param gui ScreenGui
44+
This function can be used to load a `ScreenGui` from the map into the players PlayerGUI.
4545
4646
**Example:**
4747
```lua
@@ -51,7 +51,7 @@ end
5151
5252
local ui = map:WaitForChild("MyGUI")
5353
54-
for _,player in pairs(PlayersFeature:GetPlayers()) do
54+
for _, player in pairs(PlayersFeature:GetPlayers()) do
5555
if player and player.Character then
5656
PlayerUI:LoadUI(ui)
5757
end

src/Features/Players.lua

+37-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,49 @@ local Players = {}
1515
--- @class Players
1616
--- This is a MapLib Feature. It can be accessed by `MapLib:GetFeature("Players")`.
1717

18-
--- Used to return all players in the current round.
18+
--[=[
19+
@within Players
20+
@method GetPlayers
21+
@return {Player?}
22+
23+
This function can be used to get all players in the current round.
24+
25+
**Example:**
26+
```lua
27+
--Teleports all players ingame to map.Destination.
28+
local PlayersFeature = Maplib:GetFeature("Players")
29+
local TeleportFeature = Maplib:GetFeature("Teleport")
30+
31+
for _, player in pairs(PlayersFeature:GetPlayers()) do
32+
TeleportFeature:Teleport(player, map.Destination.Position)
33+
end
34+
```
35+
]=]
36+
1937
function Players:GetPlayers(): { Player }
2038
return PlayerStates:GetPlayersWithState(PlayerStates.GAME)
2139
end
2240

2341
--[=[
24-
@since 0.11
2542
@within Players
26-
This method is used to return players in the radius of the given position.
43+
@method GetPlayersInRadius
44+
@since 0.11
45+
@param position Vector3
46+
@param radius number
47+
@return {Player?}
48+
49+
This function can be used to get all the players which are in a radius from a position.
50+
51+
**Example:**
52+
```lua
53+
--Teleports all players that are within 5 studs from map.Spawn.
54+
local PlayersFeature = Maplib:GetFeature("Players")
55+
local TeleportFeature = Maplib:GetFeature("Teleport")
56+
57+
for _, player in pairs(PlayersFeature:GetPlayersInRadius(map.Spawn.Position, 5)) do
58+
TeleportFeature:Teleport(player, map.Destination.Position)
59+
end
60+
```
2761
]=]
2862

2963
function Players:GetPlayersInRadius(position: Vector3, radius: number): { Player }

src/Features/Settings.lua

+23-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,30 @@ local Settings = { context = "client" }
1818

1919
--- @class Settings
2020
--- This is a MapLib Feature. It can be accessed by `MapLib:GetFeature("Settings")`.
21+
--- @client
22+
23+
--[=[
24+
@within Settings
25+
@method GetSetting
26+
@client
27+
28+
@param gui string
29+
@return any?
30+
This function can be used to get the value of a setting.
31+
32+
**Example:**
33+
```lua
34+
-- Changes the camera FOV to an arbitrary number and then sets it back to the saved settings value.
35+
local SettingsFeature = Maplib:GetFeature("Settings")
36+
37+
local camera = workspace.CurrentCamera
38+
39+
camera.FieldOFView = 120
40+
task.wait(3)
41+
camera.FieldOFView = SettingsFeature:GetSetting("Field Of View")
42+
```
43+
]=]
2144

22-
--- This function is used to get a player setting's value.
2345
function Settings:GetSetting(settingName: string): any?
2446
local settingsTable = SettingsModule:GetSettings()
2547

src/Features/Skills.lua

+42-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,53 @@ function Skills.new(MapLib)
1818
return self
1919
end
2020

21-
--- This function is used to toggle the sliding function on or off.
21+
--[=[
22+
@within Skills
23+
@method ToggleSliding
24+
@since 0.11
25+
@param value boolean
26+
27+
This function can be used for toggling sliding on or off during a map.
28+
29+
**Example:**
30+
```lua
31+
local SkillsFeature = Maplib:GetFeature("Skills")
32+
33+
SkillsFeature:ToggleSliding(false)
34+
task.wait(5)
35+
SkillsFeature:ToggleSliding(true)
36+
```
37+
]=]
2238
function Skills:ToggleSliding(value: boolean): ()
2339
local skills = self.map:FindFirstChild("Settings") and self.map.Settings:FindFirstChild("Skills")
2440
if skills then
2541
skills:SetAttribute("AllowSliding", value)
2642
end
2743
end
2844

45+
--[=[
46+
@within Skills
47+
@method ToggleAirDive
48+
@since 0.11
49+
@param value boolean
50+
51+
This function can be used for toggling airdive on or off during a map.
52+
53+
**Example:**
54+
```lua
55+
local SkillsFeature = Maplib:GetFeature("Skills")
56+
57+
SkillsFeature:ToggleAirDive(false)
58+
task.wait(5)
59+
SkillsFeature:ToggleAirDive(true)
60+
```
61+
]=]
62+
function Skills:ToggleAirDive(value: boolean): ()
63+
local skills = self.map:FindFirstChild("Settings") and self.map.Settings:FindFirstChild("Skills")
64+
if skills then
65+
skills:SetAttribute("AllowAirDive", value)
66+
end
67+
end
68+
69+
2970
return Skills

src/Features/Teleport.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,17 @@ local Teleport = {}
2323
@param player { Player? } | Player
2424
@param endingPosition CFrame | Vector3
2525
@param faceFront boolean
26-
Add Docs later
26+
This function can be used to teleport players.
2727
2828
**Example:**
2929
```lua
30+
--Teleports all players ingame to map.Destination and makes the camera face the front.
31+
local PlayersFeature = Maplib:GetFeature("Players")
32+
local TeleportFeature = Maplib:GetFeature("Teleport")
33+
34+
for _, player in pairs(PlayersFeature:GetPlayers()) do
35+
TeleportFeature:Teleport(player, map.Destination.Position, true)
36+
end
3037
```
3138
]=]
3239

src/init.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ end
4040
@readonly
4141
@within MapLib
4242
@prop map Model
43-
This is the map reference.
43+
This is the map model.
4444
]=]
4545

4646
--[=[
4747
@since 0.7
4848
@within MapLib
4949
@prop RoundEnding RBXScriptSignal
50-
This `RBXScriptSignal` is fired when a map ends.
50+
A `RBXScriptSignal` that is fired when a map ends.
5151
5252
**Example:**
5353
```lua

0 commit comments

Comments
 (0)