Chuyển từ Roblox sang
Nếu bạn đã làm game trong Roblox Studio, phần lớn kiến thức dùng lại được: KHIM chạy Luau, một unit bằng một stud, trọng lực như nhau, và tên API của Roblox vẫn chạy - game:GetService, Instance.new, Vector3.new, part.Position, :Connect, FindFirstChild, RemoteEvent, leaderstats... KHIM còn có tên ngắn gọn riêng, và tài liệu này dùng chúng.
Cùng ý tưởng, tên của KHIM
| Roblox | KHIM |
|---|---|
| Roblox Studio | KHIM Engine |
| Place | World (.khim) |
| Stud | Unit (cùng độ dài) |
| Creator Hub | Workshop (Xưởng) |
| Publish | Go live |
| Shift lock | Camera lock (Khoá camera) |
| Explorer / Properties | Hierarchy / Inspector |
| Toolbox | Bảng Assets |
| Output | Console |
| Packages | Linked models |
Service
| Roblox | KHIM | Trong script |
|---|---|---|
| Workspace | World | world (workspace vẫn chạy) |
| ReplicatedStorage | ReplicationService | shared |
| ServerScriptService | ServerService | game.ServerService |
| ServerStorage | StorageService | game.StorageService |
| StarterPlayerScripts, ReplicatedFirst | ClientService | game.ClientService |
| StarterGui | UI | players.me.gui (bản của người chơi) |
| Players | - | players |
| Lighting | - | lighting |
| DataStoreService | - | data |
| CollectionService | - | tags |
| UserInputService | - | input |
| TweenService | - | object:tween(...) |
| HttpService (JSON) | - | json |
| Teams | - | teams |
Lớp đối tượng
| Roblox | KHIM |
|---|---|
| LocalScript | ClientScript |
| ModuleScript | Module |
| SpawnLocation | Spawn |
| Humanoid | Body (character.body) |
| HumanoidRootPart | RootPart (character.root) |
| ClickDetector | Clickable |
| ProximityPrompt | Prompt |
| BillboardGui | Billboard |
| PointLight, SpotLight, SurfaceLight | Light |
| HingeConstraint | Hinge |
| PrismaticConstraint | Slider |
| BallSocketConstraint | BallJoint |
| SpringConstraint, RopeConstraint | Spring, Rope |
| Motor6D | Bone |
| LinearVelocity, AngularVelocity, VectorForce | Mover, Spinner, Thruster |
| ScreenGui | Canvas |
| Frame, ScrollingFrame | Panel, ScrollPanel |
| TextLabel, TextButton, TextBox | Label, Button, TextInput |
| ImageLabel, ImageButton | Image, ImageButton |
| UICorner, UIStroke, UIPadding | Corner, Border, Padding |
| UIListLayout, UIGridLayout | ListLayout, GridLayout |
| UIGradient, UIAspectRatioConstraint | Gradient, AspectRatio |
| UIScale, UISizeConstraint, UITextSizeConstraint | Scale, SizeLimit, TextSizeLimit |
Folder leaderstats | player.stats |
Cùng một đoạn code, hai cách viết
-- Tên kiểu Roblox (vẫn chạy trong KHIM)
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
end)
workspace.Coin.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
player.leaderstats.Coins.Value += 1
end
end)-- Tên của KHIM
players.joined:connect(function(player)
player.stats.Coins = 0
end)
world.Coin.touched:connect(function(hit)
local player = players.fromPart(hit)
if player then
player.stats.Coins += 1
end
end)| Roblox | KHIM |
|---|---|
Instance.new("Part", parent) | new("Part", parent) |
Vector3.new(1, 2, 3) | vec3(1, 2, 3) |
Color3.fromRGB(255, 0, 0) | rgb(255, 0, 0) |
CFrame.new(pos), CFrame.lookAt(a, b) | transform(pos), transform.lookAt(a, b) |
UDim2.new(0.5, 0, 0, 40) | dim(0.5, 0, 0, 40) |
part.Position, part.CFrame | part.position, part.transform |
:Connect, :Wait, :Disconnect | :connect, :wait, :disconnect |
FindFirstChild, WaitForChild | find, waitFor |
GetChildren, IsA, Destroy, Clone | children, isA, destroy, clone |
TweenService:Create(part, TweenInfo.new(1), goals):Play() | part:tween(goals, 1) |
RemoteEvent:FireServer(...) / .OnServerEvent | net.send(name, ...) / net.on(name, fn) |
RemoteEvent:FireClient(player, ...) / FireAllClients | net.send(player, name, ...) / net.sendAll(name, ...) |
RemoteFunction:InvokeServer / OnServerInvoke | net.call / net.handle |
DataStoreService:GetDataStore(n):GetAsync(k) | data.store(n):get(k) |
UserInputService.InputBegan | input.began, hoặc input.onKey(key, fn) |
workspace.CurrentCamera | camera |
workspace:Raycast(origin, dir) | world:raycast(origin, dir) |
Players:GetPlayerFromCharacter(hit.Parent) | players.fromPart(hit) |
humanoid:TakeDamage(10) | player:damage(10) |
game:BindToClose(fn) | game.closing:connect(fn) |
wait(1), tick() | task.wait(1), time() |
Gợi ý của KHIM Engine theo cách script được viết: script dùng tên Roblox thì được gợi ý tên Roblox.
Những điểm khác
- Part không có núm (stud). Plastic là khối có cạnh bo mềm. SmoothPlastic phẳng của Roblox là Smooth của KHIM.
- Part nặng theo vật liệu: part Metal nặng, Wood nhẹ.
applyImpulsechia cho khối lượng thật. - Camera không phải một đối tượng: nó là biến
cameratrong ClientScript. - Không có Attachment. Khớp nối, Beam và lực đẩy nhận một
anchor(mộtvec3trong không gian part của nó). - Gameplay không cần code: Teleporter, Hazard, Checkpoint, Pickup, Boost, Motion, Spawner, Seat - xem Chạm, Prompt và Zone.
- Animation là keyframe nằm trong world, làm bằng trình sửa animation của KHIM Engine; ID animation tải lên Roblox không phát được.
- Âm thanh và hình ảnh là của KHIM có sẵn hoặc bạn tải lên (có kiểm duyệt), gọi bằng
"coin"hoặc"asset:123"- asset ID của Roblox không có nghĩa ở đây. - Không gọi web:
HttpService:GetAsyncvà các hàm tương tự báo lỗi. - Script trên server đổi Decal, Light hay Highlight thì người chơi không thấy: hãy đổi chúng từ ClientScript (Âm thanh, ánh sáng và hiệu ứng).
- Chưa có trong KHIM: Terrain, SurfaceGui, ViewportFrame, MarketplaceService.
Nhập world Roblox
KHIM Engine mở được world .rbxl / .rbxlx (và model .rbxm / .rbxmx) do bạn làm: bật trình nhập trong bảng Plugins, rồi File > Import .rbxl / .rbxlx.... Cửa sổ Imported cho biết thứ gì đã sang và thứ gì bị bỏ lại.
Những gì sang được: part cùng CFrame, kích thước, màu, vật liệu; Model và Folder; script (giữ nguyên - tên Roblox vẫn chạy); weld; âm thanh, value, ClickDetector, đèn, ProximityPrompt, hạt, decal, highlight, beam và trail; UI; constraint và mover; tag và attribute; Lighting; Teams. Bị bỏ: Humanoid, Motor6D, Attachment, mesh của MeshPart (thành khối hộp), Terrain, BillboardGui và SurfaceGui, ID âm thanh và hình ảnh của Roblox.
Chỉ game của chính bạn
Chỉ xuất bản world do bạn làm hoặc bạn có quyền xuất bản. Go live một world đã nhập sẽ yêu cầu bạn xác nhận, và world bị đánh dấu là đã nhập. KHIM không liên kết với Roblox Corporation.