更新
This commit is contained in:
parent
08c59ca1d4
commit
9fced65142
110
.cursorrules
Normal file
110
.cursorrules
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
You are an expert in Luau programming, with deep knowledge of its unique features and common use cases in roblox game development and embedded systems.
|
||||
|
||||
Key Principles
|
||||
- Write clear, concise Lua code that follows idiomatic patterns
|
||||
- Leverage Lua's dynamic typing while maintaining code clarity
|
||||
- Use proper error handling and coroutines effectively
|
||||
- Follow consistent naming conventions and code organization
|
||||
- Optimize for performance while maintaining readability
|
||||
|
||||
Lua-Specific Guidelines
|
||||
- Use local variables whenever possible for better performance
|
||||
- Utilize Lua's table features effectively for data structures
|
||||
- Implement proper error handling using pcall/xpcall
|
||||
- Use metatables and metamethods appropriately
|
||||
- Follow Lua's 1-based indexing convention consistently
|
||||
|
||||
Naming Conventions
|
||||
- Use snake_case for variables and functions
|
||||
- Use PascalCase for classes/modules
|
||||
- Use UPPERCASE for constants
|
||||
- Prefix private functions/variables with underscore
|
||||
- Use descriptive names that reflect purpose
|
||||
|
||||
Code Organization
|
||||
- Group related functions into modules
|
||||
- Use local functions for module-private implementations
|
||||
- Organize code into logical sections with comments
|
||||
- Keep files focused and manageable in size
|
||||
- Use require() for module dependencies
|
||||
|
||||
Error Handling
|
||||
- Use pcall/xpcall for protected calls
|
||||
- Implement proper error messages and stack traces
|
||||
- Handle nil values explicitly
|
||||
- Use assert() for preconditions
|
||||
- Implement error logging when appropriate
|
||||
|
||||
Performance Optimization
|
||||
- Use local variables for frequently accessed values
|
||||
- Avoid global variables when possible
|
||||
- Pre-allocate tables when size is known
|
||||
- Use table.concat() for string concatenation
|
||||
- Minimize table creation in loops
|
||||
|
||||
Memory Management
|
||||
- Implement proper cleanup for resources
|
||||
- Use weak tables when appropriate
|
||||
- Avoid circular references
|
||||
- Clear references when no longer needed
|
||||
- Monitor memory usage in long-running applications
|
||||
|
||||
Testing
|
||||
- Write unit tests for critical functions
|
||||
- Use assertion statements for validation
|
||||
- Test edge cases and error conditions
|
||||
- Implement integration tests when needed
|
||||
- Use profiling tools to identify bottlenecks
|
||||
|
||||
Documentation
|
||||
- Use clear, concise comments
|
||||
- Document function parameters and return values
|
||||
- Explain complex algorithms and logic
|
||||
- Maintain API documentation
|
||||
- Include usage examples for public interfaces
|
||||
|
||||
Best Practices
|
||||
- Initialize variables before use
|
||||
- Use proper scope management
|
||||
- Implement proper garbage collection practices
|
||||
- Follow consistent formatting
|
||||
- Use appropriate data structures
|
||||
|
||||
Security Considerations
|
||||
- Validate all input data
|
||||
- Sanitize user-provided strings
|
||||
- Implement proper access controls
|
||||
- Avoid using loadstring when possible
|
||||
- Handle sensitive data appropriately
|
||||
|
||||
Common Patterns
|
||||
- Implement proper module patterns
|
||||
- Use factory functions for object creation
|
||||
- Implement proper inheritance patterns
|
||||
- Use coroutines for concurrent operations
|
||||
- Implement proper event handling
|
||||
|
||||
Game Development Specific
|
||||
- Use proper game loop structure
|
||||
- Implement efficient collision detection
|
||||
- Manage game state effectively
|
||||
- Optimize render operations
|
||||
- Handle input processing efficiently
|
||||
|
||||
Debugging
|
||||
- Use proper debugging tools
|
||||
- Implement logging systems
|
||||
- Use print statements strategically
|
||||
- Monitor performance metrics
|
||||
- Implement error reporting
|
||||
|
||||
Code Review Guidelines
|
||||
- Check for proper error handling
|
||||
- Verify performance considerations
|
||||
- Ensure proper memory management
|
||||
- Validate security measures
|
||||
- Confirm documentation completeness
|
||||
|
||||
Remember to always refer to the official Lua documentation and relevant framework documentation for specific implementation details and best practices.
|
||||
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
# Project place file
|
||||
/rbxPlanetSteroids.rbxlx
|
||||
|
||||
# Roblox Studio lock files
|
||||
/*.rbxlx.lock
|
||||
/*.rbxl.lock
|
7
aftman.toml
Normal file
7
aftman.toml
Normal file
@ -0,0 +1,7 @@
|
||||
# This file lists tools managed by Aftman, a cross-platform toolchain manager.
|
||||
# For more information, see https://github.com/LPGhatguy/aftman
|
||||
|
||||
# To add a new tool, add an entry to this table.
|
||||
[tools]
|
||||
rojo = "rojo-rbx/rojo@7.4.4"
|
||||
# rojo = "rojo-rbx/rojo@6.2.0"
|
38
default.project.json
Normal file
38
default.project.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "rbxPlanetSteroids",
|
||||
"tree": {
|
||||
"$className": "DataModel",
|
||||
|
||||
"ServerScriptService": {
|
||||
"$className": "ServerScriptService",
|
||||
"$path": "src/Server"
|
||||
},
|
||||
|
||||
"StarterPlayer": {
|
||||
"$className": "StarterPlayer",
|
||||
"StarterCharacterScripts": {
|
||||
"$className": "StarterCharacterScripts",
|
||||
"$path": "src/CharacterScripts"
|
||||
},
|
||||
"StarterPlayerScripts": {
|
||||
"$className": "StarterPlayerScripts",
|
||||
"$path": "src/StarterPlayerScripts"
|
||||
}
|
||||
},
|
||||
|
||||
"ServerStorage": {
|
||||
"$className": "ServerStorage",
|
||||
"$path": "src/ServerStorage"
|
||||
},
|
||||
|
||||
"ReplicatedStorage": {
|
||||
"$className": "ReplicatedStorage",
|
||||
"Data": {
|
||||
"$path": "src/ReplicatedStorage/Data"
|
||||
},
|
||||
"Tools": {
|
||||
"$path": "src/ReplicatedStorage/Tools"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
readme.md
18
readme.md
@ -1 +1,17 @@
|
||||
测试
|
||||
# rbxPlanetSteroids
|
||||
Generated by [Rojo](https://github.com/rojo-rbx/rojo) 7.4.4.
|
||||
|
||||
## Getting Started
|
||||
To build the place from scratch, use:
|
||||
|
||||
```bash
|
||||
rojo build -o "rbxPlanetSteroids.rbxlx"
|
||||
```
|
||||
|
||||
Next, open `rbxPlanetSteroids.rbxlx` in Roblox Studio and start the Rojo server:
|
||||
|
||||
```bash
|
||||
rojo serve
|
||||
```
|
||||
|
||||
For more help, check out [the Rojo documentation](https://rojo.space/docs).
|
29
src/Client/main.client.luau
Normal file
29
src/Client/main.client.luau
Normal file
@ -0,0 +1,29 @@
|
||||
local Players = game:GetService("Players")
|
||||
local player = Players.LocalPlayer
|
||||
|
||||
-- 等待玩家加载完成
|
||||
player:WaitForChild("GetPlayerData")
|
||||
|
||||
-- 获取玩家数据的函数
|
||||
local function getPlayerData()
|
||||
local getDataEvent = player:WaitForChild("GetPlayerData")
|
||||
getDataEvent:FireServer()
|
||||
return getDataEvent.OnClientEvent:Wait()
|
||||
end
|
||||
|
||||
-- 示例:获取并显示玩家数据
|
||||
local function displayPlayerData()
|
||||
local data = getPlayerData()
|
||||
if data then
|
||||
print("Player Data:")
|
||||
print("Score:", data.score)
|
||||
print("Level:", data.level)
|
||||
print("Lives:", data.lives)
|
||||
end
|
||||
end
|
||||
|
||||
-- 定期更新显示(每30秒)
|
||||
while true do
|
||||
displayPlayerData()
|
||||
task.wait(30)
|
||||
end
|
15
src/ReplicatedStorage/Data/AttributesData.luau
Normal file
15
src/ReplicatedStorage/Data/AttributesData.luau
Normal file
@ -0,0 +1,15 @@
|
||||
local AttributesData = {}
|
||||
|
||||
AttributesData.Data = {
|
||||
"Muscle",
|
||||
"Energy",
|
||||
"Charm",
|
||||
"Intelligence",
|
||||
|
||||
}
|
||||
|
||||
AttributesData.MaxLimit = {
|
||||
"Energy"
|
||||
}
|
||||
|
||||
return AttributesData
|
10
src/ReplicatedStorage/Data/BuffsData.luau
Normal file
10
src/ReplicatedStorage/Data/BuffsData.luau
Normal file
@ -0,0 +1,10 @@
|
||||
local BuffsData = {}
|
||||
|
||||
BuffsData.Data = {
|
||||
[301] = { name = "Speed Up" },
|
||||
[302] = { name = "Shield" },
|
||||
[303] = { name = "Double XP" },
|
||||
-- ...
|
||||
}
|
||||
|
||||
return BuffsData
|
14
src/ReplicatedStorage/Data/EquipmentsData.luau
Normal file
14
src/ReplicatedStorage/Data/EquipmentsData.luau
Normal file
@ -0,0 +1,14 @@
|
||||
local EquipmentsData = {}
|
||||
|
||||
EquipmentsData.Data = {
|
||||
[1] = {
|
||||
name = "T-shirt",
|
||||
type = "Clothing",
|
||||
attributes = {
|
||||
Muscle = 10,
|
||||
Energy = 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EquipmentsData
|
54
src/ReplicatedStorage/Data/HumanData.luau
Normal file
54
src/ReplicatedStorage/Data/HumanData.luau
Normal file
@ -0,0 +1,54 @@
|
||||
local HumanData = {}
|
||||
|
||||
HumanData.Data = {
|
||||
[1] = {
|
||||
name = "Alice",
|
||||
tags = {101, 102},
|
||||
relations = {201, 202},
|
||||
buffs = {301},
|
||||
equipment = {
|
||||
car = 401,
|
||||
house = 402,
|
||||
clothes = 403,
|
||||
},
|
||||
stats = {
|
||||
health = 100,
|
||||
strength = 50,
|
||||
intelligence = 80,
|
||||
}
|
||||
},
|
||||
[2] = {
|
||||
name = "Bob",
|
||||
tags = {103},
|
||||
relations = {203},
|
||||
buffs = {},
|
||||
equipment = {
|
||||
car = nil,
|
||||
house = 404,
|
||||
clothes = 405,
|
||||
},
|
||||
stats = {
|
||||
health = 90,
|
||||
strength = 60,
|
||||
intelligence = 70,
|
||||
}
|
||||
},
|
||||
[3] = {
|
||||
name = "Charlie",
|
||||
tags = {},
|
||||
relations = {},
|
||||
buffs = {302, 303},
|
||||
equipment = {
|
||||
car = 406,
|
||||
house = nil,
|
||||
clothes = nil,
|
||||
},
|
||||
stats = {
|
||||
health = 120,
|
||||
strength = 40,
|
||||
intelligence = 60,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HumanData
|
17
src/ReplicatedStorage/Data/ItemData.luau
Normal file
17
src/ReplicatedStorage/Data/ItemData.luau
Normal file
@ -0,0 +1,17 @@
|
||||
local ItemData = {}
|
||||
|
||||
ItemData.Data = {
|
||||
[1] = {
|
||||
name = "Health Potion",
|
||||
count = 3,
|
||||
consume_on_use = true,
|
||||
},
|
||||
[2] = {
|
||||
name = "Magic Scroll",
|
||||
count = 1,
|
||||
consume_on_use = false,
|
||||
},
|
||||
-- 可继续添加更多物品
|
||||
}
|
||||
|
||||
return ItemData
|
10
src/ReplicatedStorage/Data/RelationsData.luau
Normal file
10
src/ReplicatedStorage/Data/RelationsData.luau
Normal file
@ -0,0 +1,10 @@
|
||||
local RelationsData = {}
|
||||
|
||||
RelationsData.Data = {
|
||||
[201] = { name = "Friend" },
|
||||
[202] = { name = "Enemy" },
|
||||
[203] = { name = "Mentor" },
|
||||
-- ...
|
||||
}
|
||||
|
||||
return RelationsData
|
9
src/ReplicatedStorage/Data/TagsData.luau
Normal file
9
src/ReplicatedStorage/Data/TagsData.luau
Normal file
@ -0,0 +1,9 @@
|
||||
local TagsData = {}
|
||||
|
||||
TagsData.Data = {
|
||||
[101] = { name = "Brave" },
|
||||
[102] = { name = "Smart" },
|
||||
[103] = { name = "Strong" },
|
||||
}
|
||||
|
||||
return TagsData
|
14
src/ReplicatedStorage/Tools/Handles.luau
Normal file
14
src/ReplicatedStorage/Tools/Handles.luau
Normal file
@ -0,0 +1,14 @@
|
||||
local Handles = {}
|
||||
|
||||
-- 检查值是否存在于表中
|
||||
function Handles:valueExistsInTable(tab, value)
|
||||
for _, v in pairs(tab) do
|
||||
if v == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
return Handles
|
13
src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau
Normal file
13
src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau
Normal file
@ -0,0 +1,13 @@
|
||||
-- if not script.Parent:IsA("Frame") then return end
|
||||
|
||||
-- local Players = game:GetService("Players")
|
||||
-- local player = Players.LocalPlayer
|
||||
|
||||
-- local TB_StartGame = script.Parent.TB_StartGame
|
||||
|
||||
-- local Folder_Events = player:WaitForChild("PlayerState_Events")
|
||||
-- local RE_ChangePlayerState = Folder_Events:WaitForChild("RE_ChangePlayerState")
|
||||
|
||||
-- TB_StartGame.MouseButton1Click:Connect(function()
|
||||
-- RE_ChangePlayerState:FireServer("gameplay")
|
||||
-- end)
|
32
src/StarterPlayerScripts/Gui.client.luau
Normal file
32
src/StarterPlayerScripts/Gui.client.luau
Normal file
@ -0,0 +1,32 @@
|
||||
local function load_bil_gui()
|
||||
local player = game.Players.LocalPlayer
|
||||
local gui = player:WaitForChild("PlayerGui")
|
||||
local bil_gui = game.StarterPlayer.StarterPlayerScripts.BilGui -- BilGui 是一个文件夹
|
||||
|
||||
print("加载bilgui开始")
|
||||
-- 将 BilGui 加载到指定的 UI 预制体中
|
||||
for _, folder in ipairs(bil_gui:GetChildren()) do
|
||||
if folder:IsA("Folder") then
|
||||
local target_ui = gui:WaitForChild(folder.Name)
|
||||
if target_ui then
|
||||
for _, script in ipairs(folder:GetChildren()) do
|
||||
if script:IsA("LocalScript") then
|
||||
local target_frame = target_ui:WaitForChild(script.Name) -- 找对应脚本名字的frame
|
||||
if target_frame then
|
||||
local script_clone = script:Clone()
|
||||
script_clone.Parent = target_frame
|
||||
print("加载成功: " .. script.Name)
|
||||
else
|
||||
warn("目标 Frame 未找到: " .. script.Name)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
warn("目标 UI 预制体未找到: " .. script.Name)
|
||||
end
|
||||
end
|
||||
end
|
||||
print("加载bilgui结束")
|
||||
end
|
||||
|
||||
load_bil_gui()
|
Loading…
x
Reference in New Issue
Block a user