Trouble parsing and iterating a set from xml

JMass

Active Member
Can anyone see what I am doing wrong in the follow. I have tried duplicating the logic from other scripts but i am getting it wrong. I am not sure if it is in loading of the sets, their iteration, or both. I have been going back and forth and not finding my problem on my own.

What is happening is that ${MobsIterator.Key(exists) never evaluates as true but I am not sure why. I am working on a script to monitor for a list of mobs and resources that you define in an xml file and play a wav when they are seen. I will post it once I get it working.

Below is my test script that I cannot get to work, below it is the xml is is reading.

Thank you for any help! I am sure it is dumb mistake that will be obvious once it is pointed out.

Code:
variable bool Verbose=TRUE
variable iterator MobsIterator
variable iterator ResourcesIterator

function Startup()
{
	declare SaveDir			filepath			script "${Script.CurrentDirectory}/test/"
	mkdir "${SaveDir}"
  declare OutputFile	string				script "${Script.CurrentDirectory}/test/test_debug.log"
  declare ConfigFile	string				script "${Script.CurrentDirectory}/test/test.xml"
	call DebugIt "starting up"
	LavishSettings:Clear
	setMobs:Clear
	setResources:Clear
	LavishSettings:AddSet[Test]
	LavishSettings[Test]:AddSet[Mobs]
	LavishSettings[Test]:AddSet[Resources]
	LavishSettings[Test]:Import[${ConfigFile}]
	setMobs:Set[${LavishSettings[Test].FindSet[Mobs].GUID}]
	setResources:Set[${LavishSettings[Test].FindSet[Resources].GUID}]
}

function Shutdown()
{
  call DebugIt "shutting down"
}

function DebugIt(string aText)
{
	if ${Verbose}
	{
      echo ${aText}
	}
	redirect -append "${OutputFile}" echo "${Time}:: ${aText}"
}

function ReadPrint()
{
	;List Mobs
	call DebugIt "Listing Mobs:"	
	setMobs:GetSettingIterator[MobsIterator]
	MobsIterator:First
	while (${MobsIterator.Key(exists)})
	{
		call DebugIt "passing through while loop"
		call DebugIt "${MobsIterator.Key}"
		MobsIterator:Next
	}
}

function main()
{
	call Startup
	call ReadPrint
	call Shutdown
}
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!-- Generated by LavishSettings v2 -->
<InnerSpaceSettings>
		<Set name="Mobs">
			<Setting Name="Gruesome Grue">Gruesome Grue</Setting>
			<Setting Name="Wandering Wombat">Wandering Wombat</Setting>
		</Set>
		<Set name="Resources">
			<Setting Name="Festering Applesauce">Festering Applesauce</Setting>
		</Set>
</InnerSpaceSettings>
 

Cr4zyb4rd

Active Member
Code:
	setMobs:Clear
	setResources:Clear
What are these? I don't see them declared anywhere. It looks like you want these declared as a settingsetref type object, but unless there's some code you didn't paste, it never happens.

It also looks like you're mixing the "variable and" "declare" keywords without understanding what they do (when in doubt use "variable"), defining variables globally that are only used locally, and other such. I'd say it would probably be a good idea for you to study up on variables in general and how they're used in LavishScript.
 

JMass

Active Member
Thank you Cr4zyb4rd. That points me in the right direction. :) I will do some reading and experimenting.
 
Top Bottom