Page 1 of 1

Switch

Posted: Sat Jul 17, 2004 5:16 am
by psyco
hay guys do u have any idea why this wouldnt work?

This is what changes the scoreboard

Code: Select all

scoreboard:
	while (1) {
		switch ( local.objs )
		{
			case 0:
				setcvar "g_obj_alliedtext2" "( 0 / 2 )"
				break
			case 1:
				setcvar "g_obj_alliedtext2" "( 1 / 2 )"
				break
			case 2:
				setcvar "g_obj_alliedtext2" "( 2 / 2 )"
				break	
			Default:
				setcvar "g_obj_alliedtext2" "( 0 / 2 )"
				break	
		}
	wait 1
	}
From what i have red that should check what local.objs is and set the scoreboard to suit. At the moment it doesnt do anything to the scoreboard. i dont think there is anything in local.objs for some reason :|

i am using this to add one (1) to local.objs

Code: Select all

local.objs++
i was told that adds one onto what ever local.objs is.

and last at the top of the script i am using local.objs = 0 so it sets the scoreboard to 0. if u can help me out i would realy appreciate it

Posted: Sat Jul 17, 2004 11:43 am
by Angex
Local variables are only accessible by the thread they are created in, unless you use parameter passing. In the example below local.objs is in two different threads, but it doesn't refer to the same variable. Local.objs int the main thread has a value of 0, and the local.objs in the scoreboard is NIL or NULL.

Code: Select all

main:
    local.objs = 0

    thread scoreboard
end

scoreboard:
    switch(local.objs) {
    }
end
By making local.objs into a level variable this example would work.

level

Posted: Sat Jul 17, 2004 3:30 pm
by tltrude
Changing it to "level.objs" will work, if "level.objs" is set to one of the four numbers in another thread or script.

We would need to see the whole script, and know which game (Mohaa, SH, or BT) it is, to help more.