API

How can you use the built in API.

Built-in

Use the

game

variable to access the game in python, This is literarily the game variable in roblox.

ValidPlayers = [
    "builderman"
]

@py.Workspace.Spawn.Touched
def onTouch(touch):
    print("Spawn has been touched by", touch.Name)
    
@game.Players.PlayerAdded
def onPlrAdd(plr):
    if plr.Name in ValidPlayers:
        # The player is in our admin list, print admin joined
        print("Admin", plr.Name, "has joined the game!!")
        

The above code will do the following:

  • When a part in workspace called "Spawn" is touched print the touching parts name in the output

  • When a player joins and their name is in the ValidPlayers list that means they are a admin and output that

Compiled code:

This code generated may be outdated, code generated with newer versions of roblox-pyc should deliver better results

stringmeta, list, dict are all functions used to add the Python API to lua objects.


Embedding lua

Sometimes you need to do something in Lua, inside of a python script! But how?

Thats python code, now let's add some lua code

This is the same script but I split it to 3 different code blocks for syntax highlighting


Check out the tests in GitHub!

Last updated

Was this helpful?