Coming to Cuberite Lua from ROBLOX Lua - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Coming to Cuberite Lua from ROBLOX Lua (/thread-3042.html) |
Coming to Cuberite Lua from ROBLOX Lua - dusk - 10-23-2017 I've been scripting in Lua for as long as I can remember, and the majority of my experience is through ROBLOX. For those of you who have never used it, ROBLOX has a very vast scripting API, and its syntax is really unique and agreeable. Scripts can run either on the server or on a client. For example, take the following line, which kicks the player "dusk" from the game: game.Players.dusk:Kick() Or the following client script, which creates a new cube in the game world and places it on top of your character's head: cube = Instance.new("Part", game.Workspace) cube.Size = Vector3.new(3,3,3) --a 3x3x3 cube cube.Position = game.Players.LocalPlayer.Character.Head.Position Or the following server script, which sets a player's head on fire every time they join the game: function ignite(plr) Instance.new("Fire", plr.Character.Head) end game.Players.PlayerAdded:connect(ignite) When looking at cuberite's API, it seems to be a lot less intuitive than this, but that might just be bias because of how long I've used ROBLOX Lua. Is there any way for me to easily get familiar with Cuberite's API in the same way I am familiar with ROBLOX's? And is there anything I can do to make Cuberite plugin scripting feel more like ROBLOX scripting? Thanks RE: Coming to Cuberite Lua from ROBLOX Lua - xoft - 10-23-2017 Hello, welcome to the forum. I suppose intuitivity is subjective. For me personally, it is quite hard to see why >>Instance.new("Part", game.Workspace)<< would create a cube, and if I were to think "I want to create a cube, how do I go about it?" it would probably be quite long before I stumbled on the correct API for this (whatever Instance is). The Cuberite universe is more centered about a hierarchy of objects that is feels natural to anyone who has played Minecraft for some time - there's a world that contains blocks and entities, so if you want to change a block or create an entity, you know that you need to ask the world object to do that for you. Also Cuberite needs its plugins performant. If you want to change a cube of 50 x 50 x 50 blocks (which is not that much in Minecraft terms), the plugin will have to manipulate 125'000 blocks, and that already takes some time. Considering that a plugin may be called 20 times per second (the World Tick thread), and the numbers quickly add up. So it follows that the API is built to help speed. The only advice I can offer is the same I offer to anyone new to Cuberite plugins: Learn by example. Look at a few plugins, see how they work and go from there. |