Expanded Python Roblox Lua Tutorials
Expanded Python Roblox Lua Tutorials
## Basics
```python
# Example
x = 10 # Integer
x = "Now I'm a string!" # String
# Example: Dictionaries
person = {"name": "Ali", "age": 25, "city": "Karachi"}
print(f"{person['name']} lives in {person['city']}.")
```
## Intermediate
def info(self):
print(f"Vehicle: {self.brand} {self.model}")
class Car(Vehicle):
def start_engine(self):
print("Engine started!")
### Decorators
```python
# Example
def greet_decorator(func):
def wrapper(name):
print("Hello!")
func(name)
print("Goodbye!")
return wrapper
@greet_decorator
def greet(name):
print(f"How are you, {name}?")
greet("Ali")
```
---
# Roblox Lua Tutorials
## Advanced Topics
-- Metatable example
local t = {a = 1}
local mt = {
__index = function(table, key)
return key .. " not found!"
end
}
setmetatable(t, mt)
print(t.b) -- Output: b not found!
```
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print(hit.Parent.Name .. " touched the part!")
end
end)
```
for i = 1, 100 do
frame.Position = UDim2.new(0, i, 0, 0)
wait(0.05)
end
```