Dictionaries, Len and Math.Calc

fgamer

Member
Not an expert "coder". Done a bit in Python and a few others but there are certainly different methods in ISX than those languages .

I am having a trouble locating documentation for methods that don't involve world objects or pawns. I have seen references to this in other scripts but can't seem to locate what I need in the ISX.

1. Does ISX support dictionaries and, if so, does it also support a function similar to "dict.has_key(key)" or "key in dict" support (yes I know .has_key was deprecated in favor of "key in dict")?
2. Is there a way to return the length/count of the elements within a mutable list or dictionary? "len(dict)" would be fantastic.
3. Do I need to use the ${Math.Calc[]} for all computations? Additionally, it would appear that I need to use either :Set[] or :Inc[] to add incremental values?
Which do I use to replace something like += ? Would it be VAR:Set[${Math.Calc[VAR+Increment]}] or VAR:Inc[Increment]
Same rule applies for *= ?

I hope that all makes sense.

Appreciate the replies.
 

pr517

Active Member
Notice that all of the links are for LavishScript wiki. Read it!

A collection's (dictionary's) length can be determined with .Used or less accurately with .Size (inherited from objectcontainer).
Code:
variable collection:string Stuff

function main()
{
	Stuff:Set[Bed,1000]
	Stuff:Set[Couch,800]
	Stuff:Set[Flat-screen TV,1200]
	;Stuff:Set[Lawn Mower,200]

	if ${Stuff.Element[Lawn Mower]}
		echo "You have a Lawn Mower"
	else
		echo "You don't have a Lawn Mower"
	
	if ${Stuff.FirstKey(exists)}
	{
		echo "You have ${Stuff.Used} things:"
		do
		{
			echo "Your ${Stuff.CurrentKey} is worth $${Stuff.CurrentValue}"
		}
		while ${Stuff.NextKey(exists)}
	}
}
Yes, use Math.Calc (for floats) or Math.Calc64 (for integers) for computation. Both are 64-bit precision.
Code:
variable int a

function main()
{
	a:Set[1]
	a:Inc[${Math.Calc64[2*3]}]

	if ${a} == 7
	{
		echo Yes, this
	}
	if ${a} == 7
		echo And this, too

	/*
	if ( ${a} == 7 ) { echo You cannot do this because LavishScript is too picky }
	if ( ${a} == 7 ) {
		echo You cannot do this either because LavishScript is too picky
	}
	*/

}
 

fgamer

Member
Thanks!

Sorry for the dumb question. I didn't even think to check out LavishSoft's wiki ... just been one of those days.
 
Top Bottom