Profile
- Name
- Trim and Un-Trim scoring bug
- ID
- 109092
- Shared with
- Public
- Parent
- Bravo Cut and Close
- Children
- None
- Created on
- July 03, 2025 at 21:49 PM UTC
- Updated on
- July 03, 2025 at 22:57 PM UTC
- Description
Bravo T&UT
Best for
Code
-- this recipe just Trims and Un-Trims and checks if the score improves.
-- Initialize variables
local starting_score = current.GetScore()
local best_score = starting_score
local segment_count = structure.GetCount()
save.Quicksave(1)
-- Function to check and update the best score
function check_and_update_score(segment)
local new_score = current.GetScore()
if new_score > best_score then
gain = new_score - best_score
best_score = new_score
save.Quicksave(1)
print(" Seg: " .. segment .. " Score: " .. best_score .. " Gain: " .. gain)
return true -- Score improved
else
score_lose = (best_score - current.GetScore() )
if score_lose > 0 then
print(" segment " .. segment .. " Score lose: " .. score_lose )
end
save.Quickload(1)
return false -- Score did not improve
end
end
-- Main function
function main()
local score_improved = true
score_improved = false
-- Print the starting score
print("Starting score: " .. starting_score)
-- Loop through each segment
for i = 1, segment_count do
selection.DeselectAll()
selection.Select(i)
-- Apply a trim to the segment
structure.TrimPose()
-- Un-Trim
structure.UntrimPose()
-- Check and update the score
if check_and_update_score(i) then
score_improved = true
end
end
-- Print the best score and total gain
ending_print()
end
function ending_print()
-- Print the best score and total gain
local total_gain = best_score - starting_score
print("Best score: " .. best_score)
print("Total gain: " .. total_gain)
end
-- Error handler function
function error_handler(err)
print("Error: " .. err)
check_and_update_score(0)
ending_print()
end
-- Execute main function with error handling
xpcall(main, error_handler)