diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index 70f49decb7..1354b3e554 100644
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -2296,12 +2296,50 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLUUID dest_id, const L
else if ("lsl" == type_name)
{
const LLUUID parent_id = dest_id.notNull() ? dest_id : gInventory.findCategoryUUIDForType(LLFolderType::FT_LSL_TEXT);
+
+ // FIRE-36164 Apply the custom "New Script" setting for inventory scripts
+ bool custom_script_inserted = false;
+ if (gSavedPerAccountSettings.getBOOL("FSBuildPrefs_UseCustomScript"))
+ {
+ if (LLUUID custom_script_id(gSavedPerAccountSettings.getString("FSBuildPrefs_CustomScriptItem")); custom_script_id.notNull())
+ {
+ if (auto custom_script = gInventory.getItem(custom_script_id); custom_script && custom_script->getType() == LLAssetType::AT_LSL_TEXT)
+ {
+ LLPointer cb = NULL;
+ if (created_cb != NULL)
+ {
+ cb = new LLBoostFuncInventoryCallback(create_script_cb);
+ cb->addOnFireFunc(created_cb);
+ }
+ else
+ {
+ cb = new LLBoostFuncInventoryCallback(create_script_cb);
+ }
+ copy_inventory_item(
+ gAgent.getID(),
+ custom_script->getPermissions().getOwner(),
+ custom_script_id,
+ parent_id,
+ NEW_LSL_NAME,
+ cb);
+ custom_script_inserted = true;
+ }
+ }
+ }
+ if (!custom_script_inserted)
+ {
+ //
+
create_new_item(NEW_LSL_NAME,
parent_id,
LLAssetType::AT_LSL_TEXT,
LLInventoryType::IT_LSL,
PERM_MOVE | PERM_TRANSFER,
created_cb); // overridden in create_new_item
+
+ //
+ }
+ //
}
else if ("notecard" == type_name)
{