public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5SignatureParameter?activatorParameter = codeScope.TryGetFunctionParameterByMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR); if (activatorParameter == null) { throw new ConversionException("getActionRef in non-activator scope found. Cannot convert that one.", expected: true); } return(TES5ReferenceFactory.CreateReferenceToVariableOrProperty(activatorParameter)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { //TODO: This function is nonexistent in Papyrus and most likely should be deleted TES5SignatureParameter?containerParameter = codeScope.TryGetFunctionParameterByMeaning(TES5LocalVariableParameterMeaning.CONTAINER); if (containerParameter == null) { throw new ConversionException("GetContainer: Cannot convert to Skyrim in other contexts than onEquip/onUnequip", expected: true); } return(TES5ReferenceFactory.CreateReferenceToVariableOrProperty(containerParameter)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; TES5SignatureParameter?activatorParameter = codeScope.TryGetFunctionParameterByMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR); if (activatorParameter == null) { throw new ConversionException("isActionRef called in a context where action ref should not be present"); } string dataString = functionArguments[0].StringValue; TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(TES5ReferenceFactory.CreateReferenceToVariableOrProperty(activatorParameter), TES5ComparisonExpressionOperator.OPERATOR_EQUAL, this.referenceFactory.CreateReadReference(dataString, globalScope, multipleScriptsScope, localScope)); return(expression); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { string functionName = function.FunctionCall.FunctionName; TES4FunctionArguments functionArguments = function.Arguments; if (!functionArguments.Any()) { TES5ObjectCallArguments constantArgumentForNoFunctionArguments = new TES5ObjectCallArguments(); TES5SignatureParameter? parameterByMeaning = codeScope.TryGetFunctionParameterByMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR); if (parameterByMeaning != null) { constantArgumentForNoFunctionArguments.Add(TES5ReferenceFactory.CreateReferenceToVariableOrProperty(parameterByMeaning)); } else { constantArgumentForNoFunctionArguments.Add(TES5ReferenceFactory.CreateReferenceToPlayer(globalScope)); } constantArgumentForNoFunctionArguments.Add(new TES5Bool(true)); //Since default in oblivion is ,,skip the OnActivateBlock", this defaults to ,,abDefaultProcessingOnly = true" in Skyrim return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, constantArgumentForNoFunctionArguments)); } TES5ObjectCallArguments constantArgument = new TES5ObjectCallArguments() { this.valueFactory.CreateValue(functionArguments[0], codeScope, globalScope, multipleScriptsScope) }; ITES4StringValue?blockOnActivate = functionArguments.GetOrNull(1); bool argument1Bool; if (blockOnActivate != null) { bool blockOnActivateVal = (int)blockOnActivate.Data == 1; argument1Bool = !blockOnActivateVal; } else { argument1Bool = true; } constantArgument.Add(new TES5Bool(argument1Bool)); return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, constantArgument)); }