LavishScript Questions

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Placemate
GamingTools Subscriber
Posts: 16
Joined: Wed Oct 13, 2004 12:54 pm

LavishScript Questions

Post by Placemate » Sun May 01, 2005 4:53 am

First are there any other options for dealing with timing other than TimedCommand and ${Time} stuff like ${Time.SecondsSinceMidnight}? What I'd love to have is a variable holding execution time of a script in tenths of a second or something similar. (Execution time of a session, etc)

Secondly just a curiousity question. How hard / any possibility of getting less rigid syntax for LavishScript flow.

Such as:

if "foo" {
Meh
} else {
Beh
}

or

if "foo" Meh

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun May 01, 2005 8:51 am

1. ${System.TickCount} gives you a timestamp accurate to thousandths of a second.
2. if is just a command, and so is else. { and } have to be on their own line because the parser doesn't want to know about "if" or "else", plus your example looks ugly anyway :(

Placemate
GamingTools Subscriber
Posts: 16
Joined: Wed Oct 13, 2004 12:54 pm

Post by Placemate » Sun May 01, 2005 5:02 pm

1. Perfect, thanks

2. Shrug, I like dense code, probably because I'm too lazy to scroll.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun May 01, 2005 8:43 pm

Aside from the parser, it's all a matter of preference/style -- so don't take that as an insult or degrading. One man's trash is another man's treasure :) I prefer the extra lines because it's easier to scan through the code and see where everything is coming from.

Placemate
GamingTools Subscriber
Posts: 16
Joined: Wed Oct 13, 2004 12:54 pm

Post by Placemate » Mon May 02, 2005 12:07 pm

Actually after spending a few hours today writing code, I released how much I hate all this macroquest legacy syntax, grin.

Everytime I have to write varcalc i ${i}+1 I die a little bit inside.

That aside how much trouble would it be to add a For..Loop, and a top check while loop? I realise your pushing for 1.0 atm, so after that maybe some options so the syntax isn't as verbose.

Just trying to give feedback, overall its shaping up to be an amazing product.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Mon May 02, 2005 12:12 pm

Too much trouble to bother implementing. The current syntax for while will be the final syntax. However, you can do this:

Code: Select all

declare count int 1
do
{
  echo ${count}
}
while "$&#123;count&#58;Inc&#125;<=10"
That's basically a prefixed ++ in C, like ++count<=10

Or instead of varcalc i ${i}+1, simply:

Code: Select all

i&#58;Inc

Placemate
GamingTools Subscriber
Posts: 16
Joined: Wed Oct 13, 2004 12:54 pm

Post by Placemate » Mon May 02, 2005 12:24 pm

Just for contrast

Code: Select all

function CheckEvent&#40;&#41;
&#123;
	declare i int local
	if "!$&#123;EventsInQ&#125;"
		return
	do
	&#123;
		if "$&#123;System.TickCount&#125;>$&#123;EventTime[1]&#125;"
		&#123;
			call $&#123;EventFunction&#125;
			varset i 1
			do
			&#123;
				varset EventTime[$&#123;i&#125;] $&#123;EventTime[$&#123;Math.Calc[$&#123;i&#125;+1]&#125;]&#125;
				varset EventFunction[$&#123;i&#125;] $&#123;EventFunction[$&#123;Math.Calc[$&#123;i&#125;+1]&#125;]&#125;
				varcalc i $&#123;i&#125;+1				
			&#125;
			while "$&#123;i&#125;<$&#123;EventsInQ&#125;"
			varcalc EventsInQ $&#123;EventsInQ&#125;-1
		&#125;
	&#125;
	while "!$&#123;EventsInQ&#125; && $&#123;System.TickCount&#125;>$&#123;EventTime[1]&#125;"
&#125;
vs.

Code: Select all

function CheckEvent&#40;&#41;
&#123;
	declare i int local
	while "!$&#123;EventsInQ&#125; && $&#123;System.TickCount&#125;>$&#123;EventTime[1]&#125;"
	&#123;
		call $&#123;EventFunction&#125;
		for i = 1 to $&#123;EventsInQ&#125;
		&#123;
			varset EventTime[$&#123;i&#125;] $&#123;EventTime[$&#123;Math.Calc[$&#123;i&#125;+1]&#125;]&#125;
			varset EventFunction[$&#123;i&#125;] $&#123;EventFunction[$&#123;Math.Calc[$&#123;i&#125;+1]&#125;]&#125;
		&#125;
		varcalc EventsInQ $&#123;EventsInQ&#125;-1
	&#125;		
&#125;

Also does the math calc include short circuiting? I'm assuming no.

Placemate
GamingTools Subscriber
Posts: 16
Joined: Wed Oct 13, 2004 12:54 pm

Post by Placemate » Mon May 02, 2005 12:31 pm

Man your too quick and I can't edit. : (

Anyway I see you updated the wiki pages with methods, so I guess I'll go back to studying. Thanks for the tips.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Mon May 02, 2005 6:21 pm

Even with a for loop, it would require a beginning and an end (e.g. for..next). The difference with while is it doesnt force you to have an actual counter.

Combined with int:Inc, I think the current route is just as good if not better

Post Reply