Download src/StarterGui/CraftingGUI.client.lua from algorembrant/TimberWoods: direct link, hf CLI and curl.
- Browser
- Download file 7.8 kB
-
https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/StarterGui/CraftingGUI.client.lua
- Command line
-
hf download hf://algorembrant/TimberWoods/src/StarterGui/CraftingGUI.client.lua
-
curl -L -o CraftingGUI.client.lua https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/StarterGui/CraftingGUI.client.lua
7.8 kB
| -- src/StarterGui/CraftingGUI.client.lua | |
| -- Crafting panel showing recipes and resource counts, opened with C key | |
| local Players = game:GetService("Players") | |
| local UserInputService = game:GetService("UserInputService") | |
| local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
| local player = Players.LocalPlayer | |
| local CraftingConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("CraftingConfig")) | |
| local CraftEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("CraftEvent") | |
| local screenGui = Instance.new("ScreenGui") | |
| screenGui.Name = "CraftingGUI" | |
| screenGui.ResetOnSpawn = false | |
| screenGui.Parent = player:WaitForChild("PlayerGui") | |
| local mainFrame = Instance.new("Frame") | |
| mainFrame.Name = "CraftingFrame" | |
| mainFrame.Size = UDim2.new(0, 380, 0, 420) | |
| mainFrame.Position = UDim2.new(0.5, -190, 0.5, -210) | |
| mainFrame.BackgroundColor3 = Color3.fromRGB(30, 25, 20) | |
| mainFrame.BackgroundTransparency = 0.05 | |
| mainFrame.BorderSizePixel = 0 | |
| mainFrame.Visible = false | |
| mainFrame.Parent = screenGui | |
| local corner = Instance.new("UICorner") | |
| corner.CornerRadius = UDim.new(0, 12) | |
| corner.Parent = mainFrame | |
| local stroke = Instance.new("UIStroke") | |
| stroke.Color = Color3.fromRGB(180, 120, 50) | |
| stroke.Thickness = 2 | |
| stroke.Parent = mainFrame | |
| -- Title | |
| local titleBar = Instance.new("Frame") | |
| titleBar.Size = UDim2.new(1, 0, 0, 40) | |
| titleBar.BackgroundColor3 = Color3.fromRGB(140, 90, 30) | |
| titleBar.BorderSizePixel = 0 | |
| titleBar.Parent = mainFrame | |
| local titleCorner = Instance.new("UICorner") | |
| titleCorner.CornerRadius = UDim.new(0, 12) | |
| titleCorner.Parent = titleBar | |
| local titleLabel = Instance.new("TextLabel") | |
| titleLabel.Size = UDim2.new(1, -50, 1, 0) | |
| titleLabel.Position = UDim2.new(0, 15, 0, 0) | |
| titleLabel.BackgroundTransparency = 1 | |
| titleLabel.Text = "Crafting Table" | |
| titleLabel.TextColor3 = Color3.new(1, 1, 1) | |
| titleLabel.TextScaled = true | |
| titleLabel.Font = Enum.Font.GothamBold | |
| titleLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| titleLabel.Parent = titleBar | |
| local closeBtn = Instance.new("TextButton") | |
| closeBtn.Size = UDim2.new(0, 30, 0, 30) | |
| closeBtn.Position = UDim2.new(1, -35, 0, 5) | |
| closeBtn.BackgroundColor3 = Color3.fromRGB(180, 50, 50) | |
| closeBtn.Text = "X" | |
| closeBtn.TextColor3 = Color3.new(1, 1, 1) | |
| closeBtn.TextScaled = true | |
| closeBtn.Font = Enum.Font.GothamBold | |
| closeBtn.Parent = titleBar | |
| local closeCorner = Instance.new("UICorner") | |
| closeCorner.CornerRadius = UDim.new(0, 6) | |
| closeCorner.Parent = closeBtn | |
| closeBtn.MouseButton1Click:Connect(function() | |
| mainFrame.Visible = false | |
| end) | |
| -- Resources bar | |
| local resourceBar = Instance.new("Frame") | |
| resourceBar.Size = UDim2.new(1, -20, 0, 30) | |
| resourceBar.Position = UDim2.new(0, 10, 0, 45) | |
| resourceBar.BackgroundColor3 = Color3.fromRGB(20, 18, 15) | |
| resourceBar.BorderSizePixel = 0 | |
| resourceBar.Parent = mainFrame | |
| local resourceCorner = Instance.new("UICorner") | |
| resourceCorner.CornerRadius = UDim.new(0, 6) | |
| resourceCorner.Parent = resourceBar | |
| local resourceLabel = Instance.new("TextLabel") | |
| resourceLabel.Name = "ResourceLabel" | |
| resourceLabel.Size = UDim2.new(1, -10, 1, 0) | |
| resourceLabel.Position = UDim2.new(0, 5, 0, 0) | |
| resourceLabel.BackgroundTransparency = 1 | |
| resourceLabel.Text = "Wood: 0 | Stone: 0 | Gold: 0 | Diamond: 0" | |
| resourceLabel.TextColor3 = Color3.fromRGB(200, 180, 140) | |
| resourceLabel.TextScaled = true | |
| resourceLabel.Font = Enum.Font.GothamMedium | |
| resourceLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| resourceLabel.Parent = resourceBar | |
| -- Recipe list | |
| local scrollFrame = Instance.new("ScrollingFrame") | |
| scrollFrame.Size = UDim2.new(1, -20, 1, -90) | |
| scrollFrame.Position = UDim2.new(0, 10, 0, 80) | |
| scrollFrame.BackgroundColor3 = Color3.fromRGB(18, 15, 12) | |
| scrollFrame.BorderSizePixel = 0 | |
| scrollFrame.ScrollBarThickness = 5 | |
| scrollFrame.CanvasSize = UDim2.new(0, 0, 0, 0) | |
| scrollFrame.Parent = mainFrame | |
| local scrollCorner = Instance.new("UICorner") | |
| scrollCorner.CornerRadius = UDim.new(0, 8) | |
| scrollCorner.Parent = scrollFrame | |
| local listLayout = Instance.new("UIListLayout") | |
| listLayout.SortOrder = Enum.SortOrder.LayoutOrder | |
| listLayout.Padding = UDim.new(0, 6) | |
| listLayout.Parent = scrollFrame | |
| local scrollPad = Instance.new("UIPadding") | |
| scrollPad.PaddingTop = UDim.new(0, 5) | |
| scrollPad.PaddingLeft = UDim.new(0, 5) | |
| scrollPad.PaddingRight = UDim.new(0, 5) | |
| scrollPad.Parent = scrollFrame | |
| local currentResources = {} | |
| local function updateResourceDisplay() | |
| local wood = currentResources.Wood or 0 | |
| local stone = currentResources.Stone or 0 | |
| local gold = currentResources.GoldOre or 0 | |
| local diamond = currentResources.Diamond or 0 | |
| resourceLabel.Text = "Wood: " .. wood .. " | Stone: " .. stone .. " | Gold: " .. gold .. " | Diamond: " .. diamond | |
| end | |
| local function populateRecipes() | |
| for _, child in pairs(scrollFrame:GetChildren()) do | |
| if child:IsA("Frame") then child:Destroy() end | |
| end | |
| local idx = 0 | |
| for recipeId, recipe in pairs(CraftingConfig.Recipes) do | |
| idx = idx + 1 | |
| local card = Instance.new("Frame") | |
| card.Name = recipeId | |
| card.Size = UDim2.new(1, 0, 0, 80) | |
| card.LayoutOrder = idx | |
| card.BackgroundColor3 = Color3.fromRGB(40, 35, 28) | |
| card.BorderSizePixel = 0 | |
| card.Parent = scrollFrame | |
| local cardCorner = Instance.new("UICorner") | |
| cardCorner.CornerRadius = UDim.new(0, 8) | |
| cardCorner.Parent = card | |
| -- Name | |
| local nameLabel = Instance.new("TextLabel") | |
| nameLabel.Size = UDim2.new(0.6, 0, 0, 22) | |
| nameLabel.Position = UDim2.new(0, 8, 0, 5) | |
| nameLabel.BackgroundTransparency = 1 | |
| nameLabel.Text = recipe.Name | |
| nameLabel.TextColor3 = Color3.fromRGB(255, 220, 150) | |
| nameLabel.TextScaled = true | |
| nameLabel.Font = Enum.Font.GothamBold | |
| nameLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| nameLabel.Parent = card | |
| -- Materials list | |
| local matText = "" | |
| for mat, amount in pairs(recipe.Materials) do | |
| local have = currentResources[mat] or 0 | |
| local color = have >= amount and "OK" or "NEED" | |
| matText = matText .. mat .. ": " .. have .. "/" .. amount .. " " | |
| end | |
| local matLabel = Instance.new("TextLabel") | |
| matLabel.Name = "Materials" | |
| matLabel.Size = UDim2.new(1, -16, 0, 20) | |
| matLabel.Position = UDim2.new(0, 8, 0, 28) | |
| matLabel.BackgroundTransparency = 1 | |
| matLabel.Text = matText | |
| matLabel.TextColor3 = Color3.fromRGB(180, 170, 150) | |
| matLabel.TextScaled = true | |
| matLabel.Font = Enum.Font.Gotham | |
| matLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| matLabel.Parent = card | |
| -- Craft button | |
| local craftBtn = Instance.new("TextButton") | |
| craftBtn.Size = UDim2.new(0, 80, 0, 25) | |
| craftBtn.Position = UDim2.new(1, -88, 1, -30) | |
| craftBtn.BackgroundColor3 = Color3.fromRGB(140, 100, 30) | |
| craftBtn.Text = "CRAFT" | |
| craftBtn.TextColor3 = Color3.new(1, 1, 1) | |
| craftBtn.TextScaled = true | |
| craftBtn.Font = Enum.Font.GothamBold | |
| craftBtn.Parent = card | |
| local btnCorner = Instance.new("UICorner") | |
| btnCorner.CornerRadius = UDim.new(0, 6) | |
| btnCorner.Parent = craftBtn | |
| craftBtn.MouseButton1Click:Connect(function() | |
| CraftEvent:FireServer("Craft", recipeId) | |
| end) | |
| end | |
| task.wait() | |
| scrollFrame.CanvasSize = UDim2.new(0, 0, 0, listLayout.AbsoluteContentSize.Y + 15) | |
| end | |
| -- Listen for resource updates | |
| CraftEvent.OnClientEvent:Connect(function(action, data) | |
| if action == "ResourceUpdate" then | |
| currentResources = data or {} | |
| updateResourceDisplay() | |
| populateRecipes() | |
| end | |
| end) | |
| -- Toggle with C key | |
| UserInputService.InputBegan:Connect(function(input, gameProcessed) | |
| if gameProcessed then return end | |
| if input.KeyCode == Enum.KeyCode.C then | |
| mainFrame.Visible = not mainFrame.Visible | |
| if mainFrame.Visible then | |
| CraftEvent:FireServer("QueryResources") | |
| end | |
| end | |
| end) | |
| -- Initial populate | |
| populateRecipes() | |