From 9fced6514278fb30c82f6cdb0972415e38980550 Mon Sep 17 00:00:00 2001 From: Ggafrik <906823881@qq.com> Date: Sun, 29 Jun 2025 10:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cursorrules | 110 ++++++++++++++++++ .gitignore | 6 + aftman.toml | 7 ++ default.project.json | 38 ++++++ readme.md | 18 ++- src/Client/main.client.luau | 29 +++++ .../Data/AttributesData.luau | 15 +++ src/ReplicatedStorage/Data/BuffsData.luau | 10 ++ .../Data/EquipmentsData.luau | 14 +++ src/ReplicatedStorage/Data/HumanData.luau | 54 +++++++++ src/ReplicatedStorage/Data/ItemData.luau | 17 +++ src/ReplicatedStorage/Data/RelationsData.luau | 10 ++ src/ReplicatedStorage/Data/TagsData.luau | 9 ++ src/ReplicatedStorage/Tools/Handles.luau | 14 +++ etst.txt => src/Server/main.server.luau | 0 .../BilGui/Gui_Idle/F_Idle.client.luau | 13 +++ src/StarterPlayerScripts/Gui.client.luau | 32 +++++ 17 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 .cursorrules create mode 100644 .gitignore create mode 100644 aftman.toml create mode 100644 default.project.json create mode 100644 src/Client/main.client.luau create mode 100644 src/ReplicatedStorage/Data/AttributesData.luau create mode 100644 src/ReplicatedStorage/Data/BuffsData.luau create mode 100644 src/ReplicatedStorage/Data/EquipmentsData.luau create mode 100644 src/ReplicatedStorage/Data/HumanData.luau create mode 100644 src/ReplicatedStorage/Data/ItemData.luau create mode 100644 src/ReplicatedStorage/Data/RelationsData.luau create mode 100644 src/ReplicatedStorage/Data/TagsData.luau create mode 100644 src/ReplicatedStorage/Tools/Handles.luau rename etst.txt => src/Server/main.server.luau (100%) create mode 100644 src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau create mode 100644 src/StarterPlayerScripts/Gui.client.luau diff --git a/.cursorrules b/.cursorrules new file mode 100644 index 0000000..8f31674 --- /dev/null +++ b/.cursorrules @@ -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. + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a2242a --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Project place file +/rbxPlanetSteroids.rbxlx + +# Roblox Studio lock files +/*.rbxlx.lock +/*.rbxl.lock \ No newline at end of file diff --git a/aftman.toml b/aftman.toml new file mode 100644 index 0000000..96c6d47 --- /dev/null +++ b/aftman.toml @@ -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" \ No newline at end of file diff --git a/default.project.json b/default.project.json new file mode 100644 index 0000000..a89b717 --- /dev/null +++ b/default.project.json @@ -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" + } + } + } +} \ No newline at end of file diff --git a/readme.md b/readme.md index 61de0ed..1f95ea3 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,17 @@ -测试 \ No newline at end of file +# 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). \ No newline at end of file diff --git a/src/Client/main.client.luau b/src/Client/main.client.luau new file mode 100644 index 0000000..e9338ed --- /dev/null +++ b/src/Client/main.client.luau @@ -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 \ No newline at end of file diff --git a/src/ReplicatedStorage/Data/AttributesData.luau b/src/ReplicatedStorage/Data/AttributesData.luau new file mode 100644 index 0000000..2e7c0d3 --- /dev/null +++ b/src/ReplicatedStorage/Data/AttributesData.luau @@ -0,0 +1,15 @@ +local AttributesData = {} + +AttributesData.Data = { + "Muscle", + "Energy", + "Charm", + "Intelligence", + +} + +AttributesData.MaxLimit = { + "Energy" +} + +return AttributesData diff --git a/src/ReplicatedStorage/Data/BuffsData.luau b/src/ReplicatedStorage/Data/BuffsData.luau new file mode 100644 index 0000000..752ecbe --- /dev/null +++ b/src/ReplicatedStorage/Data/BuffsData.luau @@ -0,0 +1,10 @@ +local BuffsData = {} + +BuffsData.Data = { + [301] = { name = "Speed Up" }, + [302] = { name = "Shield" }, + [303] = { name = "Double XP" }, + -- ... +} + +return BuffsData diff --git a/src/ReplicatedStorage/Data/EquipmentsData.luau b/src/ReplicatedStorage/Data/EquipmentsData.luau new file mode 100644 index 0000000..2c101e1 --- /dev/null +++ b/src/ReplicatedStorage/Data/EquipmentsData.luau @@ -0,0 +1,14 @@ +local EquipmentsData = {} + +EquipmentsData.Data = { + [1] = { + name = "T-shirt", + type = "Clothing", + attributes = { + Muscle = 10, + Energy = 5, + } + } +} + +return EquipmentsData diff --git a/src/ReplicatedStorage/Data/HumanData.luau b/src/ReplicatedStorage/Data/HumanData.luau new file mode 100644 index 0000000..f9d780e --- /dev/null +++ b/src/ReplicatedStorage/Data/HumanData.luau @@ -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 \ No newline at end of file diff --git a/src/ReplicatedStorage/Data/ItemData.luau b/src/ReplicatedStorage/Data/ItemData.luau new file mode 100644 index 0000000..a8fe108 --- /dev/null +++ b/src/ReplicatedStorage/Data/ItemData.luau @@ -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 \ No newline at end of file diff --git a/src/ReplicatedStorage/Data/RelationsData.luau b/src/ReplicatedStorage/Data/RelationsData.luau new file mode 100644 index 0000000..10b8ff0 --- /dev/null +++ b/src/ReplicatedStorage/Data/RelationsData.luau @@ -0,0 +1,10 @@ +local RelationsData = {} + +RelationsData.Data = { + [201] = { name = "Friend" }, + [202] = { name = "Enemy" }, + [203] = { name = "Mentor" }, + -- ... +} + +return RelationsData \ No newline at end of file diff --git a/src/ReplicatedStorage/Data/TagsData.luau b/src/ReplicatedStorage/Data/TagsData.luau new file mode 100644 index 0000000..7dbe536 --- /dev/null +++ b/src/ReplicatedStorage/Data/TagsData.luau @@ -0,0 +1,9 @@ +local TagsData = {} + +TagsData.Data = { + [101] = { name = "Brave" }, + [102] = { name = "Smart" }, + [103] = { name = "Strong" }, +} + +return TagsData \ No newline at end of file diff --git a/src/ReplicatedStorage/Tools/Handles.luau b/src/ReplicatedStorage/Tools/Handles.luau new file mode 100644 index 0000000..5c21d00 --- /dev/null +++ b/src/ReplicatedStorage/Tools/Handles.luau @@ -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 diff --git a/etst.txt b/src/Server/main.server.luau similarity index 100% rename from etst.txt rename to src/Server/main.server.luau diff --git a/src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau b/src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau new file mode 100644 index 0000000..9a5b8cd --- /dev/null +++ b/src/StarterPlayerScripts/BilGui/Gui_Idle/F_Idle.client.luau @@ -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) \ No newline at end of file diff --git a/src/StarterPlayerScripts/Gui.client.luau b/src/StarterPlayerScripts/Gui.client.luau new file mode 100644 index 0000000..78d777e --- /dev/null +++ b/src/StarterPlayerScripts/Gui.client.luau @@ -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() \ No newline at end of file