Raw Documentation

This page contains documentation for all PhotonFramework methods and service Methods.

Main methods:

PhotonFramework

PhotonFramework:Start()

This method must be called before any interaction is done with the framework, as it prepares all aspects of it.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PhotonFramework = ReplicatedStorage:WaitForChild("PhotonFramework"):WaitForChild("PhotonFramework")
PhotonFramework:Start()

PhotonFramework.Objects

The Objects subtable is used to interact with both built-in objects and custom-made objects.

PhotonFramework.Objects:NewClass(ClassName:string,Class:table)

This method is used to create a new class, which can then be interacted with via the PhotonFramework.Objects:GetClass method.

PhotonFramework.Objects:NewClass("Demo Class",require(path.to.class))

PhotonFramework.Objects:GetClass(ClassName:string)

This method can be used to get the stored class data for any class that has been added to the framework (internal, custom, etc).

local DemoClass = PhotonFramework.Objects:GetClass("Demo Class")

PhotonFramework.Objects:AssignClass(Object:instance,ClassName:string)

This method is used to bind and construct a class with the supplied object.

PhotonFramework.Objects:AssignClass(workspace.SomePart,"Demo Class")

The class will have the .new method called, and with the supplied object passed as the only argument.

PhotonFramework.Objects:GetObjectClass(Object:instance)

This method will return the class bound to the object via the PhotonFramework.Objects:AssignClass method.

local DemoClass = PhotonFramework.Objects:GetObjectClass(workspace.SomePart)

PhotonFramework.Services

The services subtable is used to interact with services within the framework, both custom and built-in.

PhotonFramework.Services:GetService(ServiceName:string)

This method can be used to get a service from the framework, either a built-in one or custom one.

local CalculationService = PhotonFramework.Services:GetService("CalculationService")

PhotonFramework.Services:CreateService(ServiceName:string,Service:table,BootState:bool)

This method can be used to create a custom service within the framework.

local ServiceTable = {}
function ServiceTable:Initialize()
    print("Service initialized")
end
function ServiceTable:ping()
    print("pong")
end

PhotonFramework.Services:CreateService("CustomService",ServiceTable,false)

-- In a different script
local CustomService = PhotonFramework.Services:GetService("CustomService")
CustomService:ping() -- prints "pong"

Services:

CalculationService

CalculationService is a service that's purpose is to make physics-based calculations within the engine easy to do.

local CalculationService = PhotonFramework.Services:GetService("CalculationService")

CalculationService:GetProjectileMotionAtTime(timeValue:number,projectileInitialPosition:Vector3,projectileInitialVelocity:Vector3)

This method will return the position of a theoretical (since there is no actual projectile passed in the arguments) position at x time (timeValue). This can be used to model a projectile's path effectively.

local position = CalculationService:GetProjectileMotionAtTime(3,Vector3.new(0,5,0),Vector3.new(50,50,0))

InstanceService

InstanceService allows for easy instance creation, while it does not contain much, it's the backbone of some more complex services.

local InstanceService = PhotonFramework.Services:GetService("InstanceService")

InstanceService:Create(ClassName:string,Properties:any,Callback)

This method will create an instance with a set of defined properties, and a callback if supplied.

InstanceService:Create("Part",{
		Anchored = true;
		Material = Enum.Material.Neon;
		Parent = workspace;
	},function(part)
	while task.wait() do
		part.CFrame = part.CFrame*CFrame.Angles(0,math.rad(1),0)
	end
end)
-- the Callback property is optional.

SharedService

SharedService allows for data to be easily synced across multiple scripts. It's a big table basically.

local SharedService = PhotonFramework.Services:GetService("SharedService")

SharedService:GetValue(key:any)

This is used to retrieve a value from the service.

local value = SharedService:GetValue(true) -- Value keys can be anything really.

SharedService:SetValue(key:any,value:any)

This is used to store a value in the service.

SharedService:SetValue(true,{"ok","it's true"})

UIService

This service can be used to create advanced UIs easily with scripts.

local UIService = PhotonFramework.Services:GetService("UIService")

UIService:Create(ClassType:string)

This method can be used to create a UIService tree, which contains data to render a GUI.

local UIData = UIService:Create("ScreenGui") -- basically define the GUI type here.

UIService:Object(object:string,properties:table,children:table,connections:table,callback)

This method is used to create a UI object (such as a text button), which can then be added to a UI tree.

local object = UIService:Object("TextButton",{
    Text = "Hi";
},{
    MouseButton1Click = function()
        print("click")
    end;
},function(button)
    print(button.Name)
end)

UIService:Add(object:instance,tree:table)

This method is used to add an object to a UI tree.

UIService:Add(object,UIData)

UIService:Render(container:Instance,tree:table)

This method is used to render a UI tree.

UIService:Render(game:GetService("Players").LocalPlayer.PlayerGui,UIData)

UUIDService

UUIDService is a service that allows the creation of a unique string (for said server, does not save).

local UUIDService = PhotonFramework.Services:GetService("UUIDService")

UUIDService:GenerateUUID(length:number)

This method generates a random, unique string that is the supplied length long.

local response = UUIDService:GenerateUUID(5)
print(response) -- response will be a random string of characters.

UUIDService:GenerateUUIDCustomCharacters(length:number,characters:table)

This method generates a string of characters from a custom list.

local response = UUIDService:GenerateUUIDCustomCharacters(5,{"a","b",1,2,3})

This concludes the API documentation for now.

Last updated