while( xyz != 0) {

Post » Mon Mar 14, 2011 3:12 pm

Is it possible to use loops in the CS script language??
I've been trying to use a "while" loop and apparently the CS recognizes looping, but complains about the syntax. Specifically it says " invalid loop block structure"
if it is possible, what is the right syntax. I've tried:

while ()
{

}

without parenthesis or brackets as well, and no luck so far.

Also I've been having troubles with variables not being updated properly, specifically they are re-set to 0 for every iteration of the script.

set damage to damage + 5

yet damage is always 5. a message "damage" before the 5 confirms the variable is re-set to 0.


Sorry for asking so many things, I'm very new to the CS and I'm still a little confused with the way things work.
Thanks in advance.

PS: is there any ways to define functions??
User avatar
Nathan Barker
 
Posts: 3554
Joined: Sun Jun 10, 2007 5:55 am

Post » Mon Mar 14, 2011 5:53 pm

Check http://cs.elderscrolls.com/constwiki/index.php/User_Functions

The While need a Loop to 'close ' it

Examples:
    let n := 0    while n < 5        let n += 1        ;do stuff    Loop


    let n := 5    while ( n += -1 ) >= 0  ;  loops n times        ;do stuff    loop

User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Tue Mar 15, 2011 2:31 am

Check http://cs.elderscrolls.com/constwiki/index.php/User_Functions

The While need a Loop to 'close ' it

Examples:
    let n := 0    while n < 5        let n += 1        ;do stuff    Loop


    let n := 5    while ( n += -1 ) >= 0  ;  loops n times        ;do stuff    loop



Thank you SO MUCH.
You have opened new doors for me, lets see what I can do now.
User avatar
Sakura Haruno
 
Posts: 3446
Joined: Sat Aug 26, 2006 7:23 pm

Post » Tue Mar 15, 2011 4:06 am

Usually variables' values will persist, but when the instance the script is running on itself doesn't persist so won't the variables.
For example in a spell script the variables will always reset when the spell is cast anew. While in a quest script they should persist because quest (-objects) never get lost, even if you "stop" the quest and start it again.
If it's a base object the script is attached to, or more correctly an instance of the base object, as the base object itself is only a record and nothing "physical", the values of the variables should persist as well, as long as it's the same physical object/instance. For example an item in your inventory should be able to obtain some information once and store it, but if this item gets removed (as in deleted) and added again (now it's a new instance), its script should start fresh without any previous knowledge, i.e. variables' values will be "0" again.
User avatar
Eire Charlotta
 
Posts: 3394
Joined: Thu Nov 09, 2006 6:00 pm


Return to IV - Oblivion