rmilmine
April 13th, 2021, 05:07
I have the following for a template using the string cycler.
What is important to note about this code si that the
k and a variables in the for loop get what they are supposed to.
The sValues and sLabels are both set to what they need to be set to.
the problem I am having is that the two lines
self.parameters[1].labelsres[1] = sLabels
self.parameters[1].values[1] = sValues
do not in fact change their values.
The two Debug lines before and after those two lines show the exact same values.
If I try and leave out the dash in the xml part of the code the super.OnInit() will in fact give an error saying that they are a boolean value, which blank xml will end up being recognized as.
I'm not sure what is missing here, I've seen examples of very similar code being done.
I've tried changing this code so that it would use the name of an actual instance of the template and the error still persists.
I am running this code in unity.
<template name="cycler_knowledge_skill_type">
<button_stringcycler>
<parameters>
<defaultlabelres>dash</defaultlabelres>
<labelsres>dash</labelsres>
<values>dash</values>
</parameters>
<script>
function onInit()
local sValues = "";
local sLabels = "";
for k,a in pairs(DataCommon.knowledgeSkillData) do
if sValues ~= "" then
sValues = sValues .. "|" .. k;
else
sValues = k;
end
if sLabels ~= "" then
sLabels = sLabels .. "|" .. "knowledge_skill_type_display_label_" .. k;
else
sLabels = "knowledge_skill_type_display_label_" .. k;
end
end
Debug.console(self.parameters[1].labelsres[1]);
Debug.console(self.parameters[1].values[1]);
self.parameters[1].labelsres[1] = sLabels;
self.parameters[1].values[1] = sValues;
Debug.console(self.parameters[1].labelsres[1]);
Debug.console(self.parameters[1].values[1]);
super.onInit();
end
</script>
</button_stringcycler>
</template>
What is important to note about this code si that the
k and a variables in the for loop get what they are supposed to.
The sValues and sLabels are both set to what they need to be set to.
the problem I am having is that the two lines
self.parameters[1].labelsres[1] = sLabels
self.parameters[1].values[1] = sValues
do not in fact change their values.
The two Debug lines before and after those two lines show the exact same values.
If I try and leave out the dash in the xml part of the code the super.OnInit() will in fact give an error saying that they are a boolean value, which blank xml will end up being recognized as.
I'm not sure what is missing here, I've seen examples of very similar code being done.
I've tried changing this code so that it would use the name of an actual instance of the template and the error still persists.
I am running this code in unity.
<template name="cycler_knowledge_skill_type">
<button_stringcycler>
<parameters>
<defaultlabelres>dash</defaultlabelres>
<labelsres>dash</labelsres>
<values>dash</values>
</parameters>
<script>
function onInit()
local sValues = "";
local sLabels = "";
for k,a in pairs(DataCommon.knowledgeSkillData) do
if sValues ~= "" then
sValues = sValues .. "|" .. k;
else
sValues = k;
end
if sLabels ~= "" then
sLabels = sLabels .. "|" .. "knowledge_skill_type_display_label_" .. k;
else
sLabels = "knowledge_skill_type_display_label_" .. k;
end
end
Debug.console(self.parameters[1].labelsres[1]);
Debug.console(self.parameters[1].values[1]);
self.parameters[1].labelsres[1] = sLabels;
self.parameters[1].values[1] = sValues;
Debug.console(self.parameters[1].labelsres[1]);
Debug.console(self.parameters[1].values[1]);
super.onInit();
end
</script>
</button_stringcycler>
</template>