Page 1 of 1

Retrieve the UIName of an entity that doesn't exist

Posted: Sat Jul 04, 2015 9:00 am
by cromcrom
hello there.
I am puzzled, because, for my crafting script, I am trying, for the info panel, to show the UIName of an object .
this is part of the code below:

Code: Select all

	local component1 = Item.comp1
	local componentNumber1 = Item.compnum1
	local component2 = Item.comp2
	local componentNumber2 = Item.compnum2
	local component3 = Item.comp3
	local componentNumber3 = Item.compnum3
	local skillLevel = cromlibrary.script.checkSkillLevel(craftrequired)
	local skillLevelName = cromskills.script.translateLevel(skillLevel)
	local itemcraftingexpertise = ""
	local bonus = 0
	local itemKnowledgeVar = itemtocraft.."_craftXP"
		if cromvar.script.getVar(itemKnowledgeVar) == nil then 
		cromvar.script.setVar(itemKnowledgeVar,0)
		--print(itemKnowledgeVar)
		else
		bonus,itemcraftingexpertise = returnCraftingExpertise(itemtocraft)
		end
	local craftingSummaryText = "Craft a "..itemName..";Difficulty = "..difficulty..";Skill level= ".. skillLevelName .. " ".."Item Knowledge= "..itemcraftingexpertise.."; Major Attribute= "..majorAttribute..";Minor Attribute= "..minorAttribute.." ".."Need: "..componentNumber1.." ".. component1
my recipes are stored in a table (Item).
calling Item.comp1 returns me a string storing the name of the needed component.

I tried to get the UIName from this string, but has this object is not created yet, I can't call a findEntity, for example.
I tried all matters of
component1.go.item:getUiName(), with all variations on this subject, to no avail.
I think the problem is that the game doesn't identify this string as the name of an object.

Any ideas please ?

Re: Retrieve the UIName of an entity that doesn't exist

Posted: Sat Jul 04, 2015 11:01 am
by AndakRainor
I had a similar problem when I needed some info on spells. As they are definitions and not actual GameObjects, I did not find any way in the scripting reference to access those definitions' details.

So I used this solution: I put all the spells definitions in a table and loop through it on initialization to call the define function on all elements of this table. This way I am sure the table and the definitions are strictly the same, and I have a table available to get any value I need about those definitions.

You could do the same with all items, or at least those you need in your crafting system.

Re: Retrieve the UIName of an entity that doesn't exist

Posted: Sat Jul 04, 2015 11:05 am
by cromcrom
Sounds good, thanks for the tip.