Update wiki with new roblox builtin

This commit is contained in:
Filip Tibell 2023-03-22 20:08:55 +01:00
parent 40161efbb4
commit d802288906
No known key found for this signature in database
5 changed files with 161 additions and 30 deletions

View file

@ -26,8 +26,11 @@ Note that Lune does not make any minimum supported rust version (MSRV) guarantee
### Using GitHub Releases
You can download pre-built binaries for most systems directly from the [GitHub Releases](https://github.com/filiptibell/lune/releases) page. <br />
There are many tools that can install directly from releases, and it is up to you to choose what tool to use when installing using this method.
There are many tools that can install binaries directly from releases, and it is up to you to choose what tool to use when installing here.
## Next steps
Now that you've installed Lune, head over to the [Writing Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---2-Writing-Scripts) page to write your first script!
Congratulations! You've installed Lune and are now ready to write your first script.
- If you want to write standalone scripts, head over to the [Writing Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---2-Writing-Scripts) page.
- If you want to write Lune scripts specifically for Roblox, check out the [Roblox](https://github.com/filiptibell/lune/wiki/Roblox) section.

View file

@ -0,0 +1,69 @@
<!-- markdownlint-disable MD033 -->
<!-- markdownlint-disable MD026 -->
# Classes
## `Instance`
Currently implemented APIs:
- [`new`](https://create.roblox.com/docs/reference/engine/datatypes/Instance#new) - note that this does not include the second `parent` argument
- [`Clone`](https://create.roblox.com/docs/reference/engine/classes/Instance#Clone)
- [`Destroy`](https://create.roblox.com/docs/reference/engine/classes/Instance#Destroy)
- [`ClearAllChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#ClearAllChildren)
- [`FindFirstAncestor`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstAncestor)
- [`FindFirstAncestorOfClass`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstAncestorOfClass)
- [`FindFirstAncestorWhichIsA`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstAncestorWhichIsA)
- [`FindFirstChild`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstChild)
- [`FindFirstChildOfClass`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstChildOfClass)
- [`FindFirstChildWhichIsA`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstChildWhichIsA)
- [`FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant)
- [`GetChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetChildren)
- [`GetDescendants`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetDescendants)
- [`GetFullName`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetFullName)
- [`IsA`](https://create.roblox.com/docs/reference/engine/classes/Instance#IsA)
- [`IsAncestorOf`](https://create.roblox.com/docs/reference/engine/classes/Instance#IsAncestorOf)
- [`IsDescendantOf`](https://create.roblox.com/docs/reference/engine/classes/Instance#IsDescendantOf)
Not yet implemented, but planned:
- [`GetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttribute)
- [`GetAttributes`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttributes)
- [`SetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#SetAttribute)
## `DataModel`
Currently implemented APIs:
- [`GetService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#GetService)
- [`FindService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#FindService)
# Datatypes
Currently implemented datatypes:
- [`Axes`](https://create.roblox.com/docs/reference/engine/datatypes/Axes)
- [`BrickColor`](https://create.roblox.com/docs/reference/engine/datatypes/BrickColor)
- [`CFrame`](https://create.roblox.com/docs/reference/engine/datatypes/CFrame)
- [`Color3`](https://create.roblox.com/docs/reference/engine/datatypes/Color3)
- [`ColorSequence`](https://create.roblox.com/docs/reference/engine/datatypes/ColorSequence)
- [`ColorSequenceKeypoint`](https://create.roblox.com/docs/reference/engine/datatypes/ColorSequenceKeypoint)
- [`Enum`](https://create.roblox.com/docs/reference/engine/datatypes/Enum)
- [`Faces`](https://create.roblox.com/docs/reference/engine/datatypes/Faces)
- [`Font`](https://create.roblox.com/docs/reference/engine/datatypes/Font)
- [`NumberRange`](https://create.roblox.com/docs/reference/engine/datatypes/NumberRange)
- [`NumberSequence`](https://create.roblox.com/docs/reference/engine/datatypes/NumberSequence)
- [`NumberSequenceKeypoint`](https://create.roblox.com/docs/reference/engine/datatypes/NumberSequenceKeypoint)
- [`PhysicalProperties`](https://create.roblox.com/docs/reference/engine/datatypes/PhysicalProperties)
- [`Ray`](https://create.roblox.com/docs/reference/engine/datatypes/Ray)
- [`Rect`](https://create.roblox.com/docs/reference/engine/datatypes/Rect)
- [`Region3`](https://create.roblox.com/docs/reference/engine/datatypes/Region3)
- [`Region3int16`](https://create.roblox.com/docs/reference/engine/datatypes/Region3int16)
- [`UDim`](https://create.roblox.com/docs/reference/engine/datatypes/UDim)
- [`UDim2`](https://create.roblox.com/docs/reference/engine/datatypes/UDim2)
- [`Vector2`](https://create.roblox.com/docs/reference/engine/datatypes/Vector2)
- [`Vector2int16`](https://create.roblox.com/docs/reference/engine/datatypes/Vector2int16)
- [`Vector3`](https://create.roblox.com/docs/reference/engine/datatypes/Vector3)
- [`Vector3int16`](https://create.roblox.com/docs/reference/engine/datatypes/Vector3int16)
Note that these datatypes are kept as up-to-date as possible, but some very new members may be missing.

82
docs/pages/Roblox.md Normal file
View file

@ -0,0 +1,82 @@
<!-- markdownlint-disable MD033 -->
<!-- markdownlint-disable MD026 -->
# ✏️ Writing Lune Scripts for Roblox
Lune has a powerful built-in library and set of APIs for manipulating Roblox place files and model files. It contains APIs for reading & writing files, and gives you instances to use, just as if you were scripting inside of the Roblox engine, albeit with a more limited API.
For a full list of the currently implemented APIs, check out the [API Reference](https://github.com/filiptibell/lune/wiki/Roblox---API-Reference) page.
## Example Scripts
### `1` - Make all parts anchored in a place file
```lua
local roblox = require("@lune/roblox")
-- Read the place file called myPlaceFile.rbxl into a DataModel called "game"
-- This works exactly the same as in Roblox, except "game" does not exist by default - you have to load it from a file!
local game = roblox.readPlaceFile("myPlaceFile.rbxl")
local workspace = game:GetService("Workspace")
-- Make all of the parts in the workspace anchored
for _, descendant in workspace:GetDescendants() do
if descendant:IsA("BasePart") then
descendant.Anchored = true
end
end
-- Save the DataModel (game) back to the file that we read it from
roblox.writePlaceFile("myPlaceFile.rbxl")
```
---
### `2` - Save instances in a place as individual model files
```lua
local roblox = require("@lune/roblox")
local fs = require("@lune/fs")
-- Here we load a file just like in the first example
local game = roblox.readPlaceFile("myPlaceFile.rbxl")
local workspace = game:GetService("Workspace")
-- We use a normal Lune API to make sure a directory exists to save our models in
fs.writeDir("models")
-- Then we save all of our instances in Workspace as model files, in our new directory
-- Note that a model file can actually contain several instances at once, so we pass a table here
for _, child in workspace:GetChildren() do
roblox.writeModelFile("models/" .. child.Name, { child })
end
```
---
### `3` - Make a new place from scratch
```lua
local roblox = require("@lune/roblox")
local Instance = roblox.Instance
-- You can even create a new DataModel using Instance.new, which is not normally possible in Roblox
-- This is normal - most instances that are not normally accessible in Roblox can be manipulated using Lune!
local game = Instance.new("DataModel")
local workspace = game:GetService("Workspace")
-- Here we just make a bunch of models with parts in them for demonstration purposes
for i = 1, 50 do
local model = Instance.new("Model")
model.Name = "Model #" .. tostring(i)
model.Parent = workspace
for j = 1, 4 do
local part = Instance.new("Part")
part.Name = "Part #" .. tostring(j)
part.Parent = model
end
end
-- As always, we have to save the DataModel (game) to a file when we're done
roblox.writePlaceFile("myPlaceWithLotsOfModels.rbxl")
```

View file

@ -8,6 +8,11 @@
- [3. Running Scripts](https://github.com/filiptibell/lune/wiki/Getting-Started---3-Running-Scripts)
- [4. Editor Setup](https://github.com/filiptibell/lune/wiki/Getting-Started---4-Editor-Setup)
# Roblox
- [Getting Started](https://github.com/filiptibell/lune/wiki/Roblox)
- [API Reference](https://github.com/filiptibell/lune/wiki/Roblox---API-Reference)
# API Reference
- [FS](https://github.com/filiptibell/lune/wiki/API-Reference---FS)

View file

@ -764,34 +764,6 @@ impl LuaUserData for Instance {
/*
Implementations of base methods on the Instance class
Currently implemented:
* Clone
* Destroy
* ClearAllChildren
* FindFirstAncestor
* FindFirstAncestorOfClass
* FindFirstAncestorWhichIsA
* FindFirstChild
* FindFirstChildOfClass
* FindFirstChildWhichIsA
* FindFirstDescendant
* GetChildren
* GetDescendants
* GetFullName
* IsA
* IsAncestorOf
* IsDescendantOf
Not yet implemented, but planned:
* GetAttribute
* GetAttributes
* SetAttribute
It should be noted that any methods that deal with events
and/or have functionality that affects instances other
than this instance itself are intentionally left out.