diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md new file mode 100644 index 0000000..374cc3b --- /dev/null +++ b/docs/tutorials/index.md @@ -0,0 +1,7 @@ +--- +title: Tutorials +weight: 3 +empty: true +--- + +# Tutorials \ No newline at end of file diff --git a/docs/tutorials/migration.md b/docs/tutorials/migration.md new file mode 100644 index 0000000..02c4101 --- /dev/null +++ b/docs/tutorials/migration.md @@ -0,0 +1,80 @@ +--- +title: Migrating to 2.0 +description: Guide on how you can migrate your place to 2.0 +--- + +!! WORK IN PROGRESS !! + +# Migrating to 2.0 + +Tutorial on how to migrate to 2.0 + +## Lua 5.2 -> Luau + +This is the biggest compatibility breaking change for 2.0. The transition from Lua 5.2 (Moonsharp) to Luau. One of the big change being the now non-available `goto` statements. Which you'll have to switch to `continue` statement instead. + +## Tweening + +Tweening has been revamped in 2.0. You should create a tween object first, then tween it from there. Example: + +```lua +local part: Part = script.Parent +local origin = part.Position +local tw = Tween:NewTween() + +print("Tween Start!") + +tw:TweenVector3(origin, origin + Vector3.New(0, 10, 0), 10, function(val) + part.Position = val +end) + +tw.Finished:Wait() + +print("Tween Finished!") +``` + +## Particles + +Particles has been revamped in 2.0. + +## Datastore retrieving + +Datastore now no longer requires waiting for it to load first. + +```lua +local ds = Datastore:GetDatastore("datastore1") +ds:SetAsync("coins", 11) +local coins: number = ds:GetAsync("coins") +print(coins) +``` + +You may notice that these function now require Async suffix, which brings us to: + +## Async functions + +Some function will now be required to be async in non compatibility mode. These include but not limited to: Http requests, Datastore data retrieving, Insert via InsertService etc. + +Example HTTP Request made with 2.0: + +```lua +local success, res = pcall(function() + return Http:GetAsync("http://example.com/") +end) +print(success, res) +``` + +To run multiple tasks simultaneously, use `spawn` + +```lua +spawn(function() + local success, res = pcall(function() + return Http:GetAsync("https://example.com") + end) + print(success, res) +end) + +local ds = Datastore:GetDatastore("datastore1") +ds:SetAsync("coins", 11) +local coins: number = ds:GetAsync("coins") +print(coins) +``` \ No newline at end of file