Adds feature to remove transformations
This commit is contained in:
1 parent
dc9d1f2c7d
commit
ae17925f58
3 files changed
+51
-14
No files matched your search
@@ -4,6 +4,9 @@ EID.CustomTransformations = {}
|
|||||||
-- Format: [ID.VARIANT.SUBTYPE] = "Transformation Basename or id"
|
-- Format: [ID.VARIANT.SUBTYPE] = "Transformation Basename or id"
|
||||||
EID.CustomTransformAssignments = {}
|
EID.CustomTransformAssignments = {}
|
||||||
|
|
||||||
|
-- Format: [ID.VARIANT.SUBTYPE] = "Transformation Basename or id"
|
||||||
|
EID.CustomTransformRemovals = {}
|
||||||
|
|
||||||
-- default transformations
|
-- default transformations
|
||||||
-- Format: [ID.VARIANT.SUBTYPE] = "Transformation string"
|
-- Format: [ID.VARIANT.SUBTYPE] = "Transformation string"
|
||||||
EID.EntityTransformations = {
|
EID.EntityTransformations = {
|
||||||
|
|||||||
+46
-13
@@ -90,7 +90,7 @@ function EID:createTransformation(uniqueName, displayName, language)
|
|||||||
EID.CustomTransformations[uniqueName][language] = displayName
|
EID.CustomTransformations[uniqueName][language] = displayName
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Assigns transformations to an entity
|
-- Assigns transformations to an entity (Adds to existing transformations)
|
||||||
-- valid target types: [collectible, trinket, card, pill, entity]
|
-- valid target types: [collectible, trinket, card, pill, entity]
|
||||||
-- when type = entity, targetIdentifier must be in the format "ID.Variant.subtype". for any other type, it can just be the id
|
-- when type = entity, targetIdentifier must be in the format "ID.Variant.subtype". for any other type, it can just be the id
|
||||||
-- EXAMPLE: EID:assignTransformation("collectible", 1, "My Transformation")
|
-- EXAMPLE: EID:assignTransformation("collectible", 1, "My Transformation")
|
||||||
@@ -104,6 +104,24 @@ function EID:assignTransformation(targetType, targetIdentifier, transformationSt
|
|||||||
EID.CustomTransformAssignments[entryID] = transformationString
|
EID.CustomTransformAssignments[entryID] = transformationString
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Removes a transformation of an entity
|
||||||
|
-- valid target types: [collectible, trinket, card, pill, entity]
|
||||||
|
-- when type = entity, targetIdentifier must be in the format "ID.Variant.subtype". for any other type, it can just be the id
|
||||||
|
-- EXAMPLE: EID:removeTransformation("collectible", 1, "My Transformation")
|
||||||
|
function EID:removeTransformation(targetType, targetIdentifier, transformationString)
|
||||||
|
local entryID = EID:getIDVariantString(targetType)
|
||||||
|
if entryID ~= nil then
|
||||||
|
entryID = entryID.."."..targetIdentifier
|
||||||
|
else
|
||||||
|
entryID = targetIdentifier
|
||||||
|
end
|
||||||
|
if EID.CustomTransformRemovals[entryID] == nil then
|
||||||
|
EID.CustomTransformRemovals[entryID] = transformationString
|
||||||
|
else
|
||||||
|
EID.CustomTransformRemovals[entryID] = EID.CustomTransformRemovals[entryID]..","..transformationString
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Adds a description for a an Entity. Optional parameters: language, transformations
|
-- Adds a description for a an Entity. Optional parameters: language, transformations
|
||||||
-- when subtype is -1 or empty, it will affect all subtypes of that entity
|
-- when subtype is -1 or empty, it will affect all subtypes of that entity
|
||||||
function EID:addEntity(id, variant, subtype, entityName, description, language)
|
function EID:addEntity(id, variant, subtype, entityName, description, language)
|
||||||
@@ -245,7 +263,7 @@ function EID:getDescriptionObj(Type, Variant, SubType)
|
|||||||
local tableEntry = EID:getDescriptionData(Type, Variant, description.ID)
|
local tableEntry = EID:getDescriptionData(Type, Variant, description.ID)
|
||||||
description.Description =tableEntry and tableEntry[3] or "MISSING DESCRIPTION"
|
description.Description =tableEntry and tableEntry[3] or "MISSING DESCRIPTION"
|
||||||
|
|
||||||
description.Transformation = EID:getTransformation(description.fullItemString)
|
description.Transformation = EID:getTransformation(Type, Variant, description.ID)
|
||||||
|
|
||||||
return description
|
return description
|
||||||
end
|
end
|
||||||
@@ -287,20 +305,35 @@ function EID:getDescriptionData(Type, Variant, SubType)
|
|||||||
return moddedDesc or legacyModdedDescription or defaultDesc
|
return moddedDesc or legacyModdedDescription or defaultDesc
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the transformation uniqueName / ID of a given "ID.Variant.Subtype" pair
|
-- Get the transformation uniqueName / ID of a given entity
|
||||||
-- Example: EID:getTransformation("5.100.34") will return "12" which is the id for Bookworm
|
-- Example: EID:getTransformation(5,100,34) will return "12" which is the id for Bookworm
|
||||||
function EID:getTransformation(entityIdentifier)
|
function EID:getTransformation(id, variant, subType)
|
||||||
local custom = EID.CustomTransformAssignments[entityIdentifier]
|
local entityString = id.."."..variant.."."..subType
|
||||||
|
local listToTest = ""
|
||||||
|
local default = EID.EntityTransformations[entityString]
|
||||||
|
if default~= nil then listToTest = default end
|
||||||
|
|
||||||
local customLegacy = nil
|
local customLegacy = nil
|
||||||
local splitString = {}
|
if id == 5 and variant == 100 then
|
||||||
for identifier in string.gsub(entityIdentifier,"%f[.]%.%f[^.]", "\0"):gmatch("%Z+") do
|
customLegacy = __eidItemTransformations[subType]
|
||||||
table.insert(splitString,identifier)
|
if customLegacy~= nil then listToTest = listToTest..","..customLegacy end
|
||||||
end
|
end
|
||||||
if splitString[1] == "5" and splitString[2] == "100" then
|
|
||||||
customLegacy = __eidItemTransformations[splitString[3]]
|
local custom = EID.CustomTransformAssignments[entityString]
|
||||||
|
if custom~= nil then listToTest = listToTest..","..custom end
|
||||||
|
|
||||||
|
local transformationList = ""
|
||||||
|
local removedList = EID.CustomTransformRemovals[entityString]
|
||||||
|
for transform in string.gmatch(listToTest, "([^,]+)") do
|
||||||
|
local isRemoved = false
|
||||||
|
if removedList ~= nil then
|
||||||
|
for removedTransform in string.gmatch(removedList, "([^,]+)") do
|
||||||
|
if transform == removedTransform then isRemoved = true end
|
||||||
end
|
end
|
||||||
local default = EID.EntityTransformations[entityIdentifier]
|
end
|
||||||
return custom or customLegacy or default or "0"
|
if not isRemoved then transformationList = transformationList..","..transform end
|
||||||
|
end
|
||||||
|
return transformationList
|
||||||
end
|
end
|
||||||
|
|
||||||
--Get the name of the given transformation by its uniqueName / ID
|
--Get the name of the given transformation by its uniqueName / ID
|
||||||
|
|||||||
+2
-1
@@ -58,7 +58,8 @@ EID:addIcon("NewTransform1", "hearts", 2, 9, 9, -1, 0, dummySprite)
|
|||||||
EID:createTransformation("NewTransform1", "New transformation") -- Transformation
|
EID:createTransformation("NewTransform1", "New transformation") -- Transformation
|
||||||
EID:createTransformation("NewTransform1", "New russian transformation", "ru") -- add Transformation name in russian
|
EID:createTransformation("NewTransform1", "New russian transformation", "ru") -- add Transformation name in russian
|
||||||
|
|
||||||
EID:assignTransformation("collectible", 5, "NewTransform1") -- Add Transformation to My Reflection
|
EID:assignTransformation("collectible", 5, "NewTransform1,2,3") -- Add Transformation to My Reflection
|
||||||
|
EID:removeTransformation("collectible", 5, "2") -- Removes a transformation
|
||||||
|
|
||||||
------ Test: Add all transformations + some customs ones to Inner Eye ------
|
------ Test: Add all transformations + some customs ones to Inner Eye ------
|
||||||
EID:assignTransformation("collectible", 2, "1,2,3,4,5,6,7,8,9,10,11,12,13,something Custom,NewTransform1")
|
EID:assignTransformation("collectible", 2, "1,2,3,4,5,6,7,8,9,10,11,12,13,something Custom,NewTransform1")
|
||||||
|
|||||||
Reference in new issue
Block a user