Skip to content

Getting Started

1Humza edited this page Oct 22, 2021 · 23 revisions

Here I will show you basic usage of the framework so you can grasp some sort of workflow.

Using the Module Loader

At the core of Evolve is the module loader. You should require it at the beginning of every script.

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Evolve"))

It's not the prettiest line of code but it allows us to then require our modules very easily.

local CO = require("CustomObjects")

Create a Class

The first thing you need to do is make a class.

--Door Class Module Script
local Door = {}

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Evolve")) --Require module loader

function Door.new(Color) --This function is only called when 'new' function through Custom Objects module.
   local newDoor = Instance.new("Part")
   newDoor.BrickColor = Color --Parameters are passed through to this constructor from 'new' function of Custom Objects module.
   return newDoor --Returns an Instance of which wrapper will be applied to.
end

function Door:Initialize() --Called every time Custom Object is created using this class after 'new' function. Also runs when 'Clone' is called on a CustomObject.
   self.Opened = false
end


--Below are user defined functions of the class--

function Door:Open()
   self.Opened = true
end

function Door:Close()
   self.Opened = false
end

function Door:IsOpen()
   return self.Opened
end

return Door

You are half way there! Now we just need to create our Door using the class module we created.

--Some script

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Evolve")) --Require module loader
local CO = require("CustomObjects") --Require "CustomObjects" module

local redDoor = CO.new("Door",BrickColor.new("Bright Red")) --Returns new Part that is red wrapped with our class!
--This is when 'Initialize' within our class is called.

print(redDoor:IsOpen()) --prints 'false' since we initialized the variable as false in our class.

redDoor:Open()

print(redDoor:IsOpen()) --prints 'true' since variable is set to true in code above.

redDoor.Opened = false --since the variable is assigned as a property of the Door we can skip using the function and set the value ourselves.

print(redDoor:IsOpen()) --prints 'false'

Replication

Since the above code creates a new Custom Object with our Door class, it's currently parented to nil. Replication only occurs when the base instance is parented to a replicated directory.

Replicated Directories

Properties of objects parented to any of the below will replicate state changes to clients.

  • Workspace
  • Players
  • Lighting
  • ReplicatedStorage
  • StarterGui
  • StarterPack
  • StarterPlayer
Non Replicated Directories

Properties of objects parented to the below will NOT replicate state changes to clients.

  • ReplicatedFirst
  • NetworkClient
  • ServerScriptService
  • ServerStorage
  • nil

NOTE: This is true outside of this framework; it is standard Roblox replication behavior.

--Some localscript

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Evolve")) --Require module loader
local CO = require("CustomObjects") --Require "CustomObjects" module

CO:Wrap(

Clone this wiki locally