1
This commit is contained in:
commit
a85391509d
211 files changed
+28903
No files matched your search
@@ -0,0 +1,76 @@
|
||||
-- Studio plugin: keeps the weapon position tuned in a playtest.
|
||||
-- In the playtest client, the ViewmodelTuner "Сохранить" button sets the SavedTune attribute
|
||||
-- (JSON) on PlayerScripts.SniperViewmodel; this plugin stores it with plugin:SetSetting.
|
||||
-- In Edit, it applies the latest stored values to the attributes of
|
||||
-- StarterPlayer.StarterPlayerScripts.SniperViewmodel, so they are saved with the place.
|
||||
-- Install: copy to %LOCALAPPDATA%\Roblox\Plugins\
|
||||
|
||||
local RunService = game:GetService("RunService")
|
||||
local HttpService = game:GetService("HttpService")
|
||||
|
||||
local SETTING = "HunterViewmodelTune"
|
||||
local SCRIPT_NAME = "SniperViewmodel"
|
||||
|
||||
if RunService:IsRunning() then
|
||||
if not RunService:IsClient() then
|
||||
return
|
||||
end
|
||||
local Players = game:GetService("Players")
|
||||
local player = Players.LocalPlayer
|
||||
while not player do
|
||||
task.wait(0.2)
|
||||
player = Players.LocalPlayer
|
||||
end
|
||||
local target = player:WaitForChild("PlayerScripts"):WaitForChild(SCRIPT_NAME, 60)
|
||||
if not target then
|
||||
return
|
||||
end
|
||||
target:GetAttributeChangedSignal("SavedTune"):Connect(function()
|
||||
local json = target:GetAttribute("SavedTune")
|
||||
if typeof(json) == "string" and json ~= "" then
|
||||
plugin:SetSetting(SETTING, json)
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
-- Edit mode: apply anything saved during a playtest (once: the applied save id is remembered,
|
||||
-- so later manual edits of the attributes are not overwritten on the next Studio start).
|
||||
local APPLIED = SETTING .. "Applied"
|
||||
local lastApplied = plugin:GetSetting(APPLIED)
|
||||
local function apply()
|
||||
local ok, json = pcall(function()
|
||||
return plugin:GetSetting(SETTING)
|
||||
end)
|
||||
if not ok or typeof(json) ~= "string" or json == lastApplied then
|
||||
return
|
||||
end
|
||||
local okDecode, data = pcall(HttpService.JSONDecode, HttpService, json)
|
||||
if not okDecode or typeof(data) ~= "table" then
|
||||
return
|
||||
end
|
||||
local target = game:GetService("StarterPlayer").StarterPlayerScripts:FindFirstChild(SCRIPT_NAME)
|
||||
if not target then
|
||||
return
|
||||
end
|
||||
lastApplied = json
|
||||
plugin:SetSetting(APPLIED, json)
|
||||
local changed = false
|
||||
for key, value in data.values or {} do
|
||||
if typeof(value) == "number" and target:GetAttribute(key) ~= value then
|
||||
target:SetAttribute(key, value)
|
||||
changed = true
|
||||
end
|
||||
end
|
||||
if changed then
|
||||
game:GetService("ChangeHistoryService"):SetWaypoint("Apply tuned viewmodel position")
|
||||
print("[ViewmodelTuneSaver] weapon position saved to StarterPlayerScripts." .. SCRIPT_NAME)
|
||||
end
|
||||
end
|
||||
|
||||
task.spawn(function()
|
||||
while true do
|
||||
apply()
|
||||
task.wait(1)
|
||||
end
|
||||
end)
|
||||
Reference in new issue
Block a user