mapascripting accum problem


(merlin1991) #1

i have created a script for an elevator with 2 floors 2 script movers each floor as doors and 1 script mover for the elevator, it starts at ground floor

the problem is that when it is at 1st floor accum 2 should be set 1 and when the moving down script gets called that one is checked if it is at 2, but: the value gets never 1 i just can’t get it moving when it has moved up

here the script:

elevator_move
{
	spawn
	{
		accum 1 set 0	//button to open or close doors
		accum 2 set 0	//elevator floor
		accum 3 set 0	//elevator moving? 0 = no, 1 = yes
	}

	trigger button		//button to open all doors called
	{
		accum 1 trigger_if_equal 0 elevator_move button_0
		accum 1 trigger_if_equal 1 elevator_move button_1
	}

	trigger button_0
	{
		wait 10		//wait that trigger button works
		accum 2 trigger_if_equal 0 elevator_move open_1stfloor
		accum 2 trigger_if_equal 1 elevator_move open_ground
		accum 1 set 1
	}

	trigger button_1
	{
		wait 10		//wait that trigger button works
		accum 2 trigger_if_equal 0 elevator_move close_1stfloor
		accum 2 trigger_if_equal 1 elevator_move close_ground
		accum 1 set 0
	}

	trigger move_ground
	{
		accum 3 abort_if_not_equal 0	//already moving?
		wm_announce "not moving"
		accum 2 abort_if_not_equal 1	//really 1stfloor?
		wm_announce "i'm 1stfloor"
		accum 3 set 1
		accum 1 trigger_if_equal 0 elevator_move close_1stfloor
		wait 1200			//wait for doors to close
		trigger elevator groundfloor
		wait 2500			//wait till elevator is at groundflor
		accum 1 trigger_if_equal 0 elevator_move open_groundfloor
		wm_announce "i'm groundfloor"
		accum 2 set 0
		accum 3 set 0
	}

	trigger move_1stfloor
	{
		accum 3 abort_if_not_equal 0	//already moving?
		wm_announce "not moving"
		accum 2 abort_if_not_equal 0	//really groundfloor?
		wm_announce "i'm groundfloor"
		accum 3 set 1
		accum 1 trigger_if_equal 0 elevator_move close_ground
		wait 1200			//wait for doors to close
		trigger elevator 1stfloor
		wait 2500			//wait till elevator is at 1stflor
		accum 1 trigger_if_equal 0 elevator_move open_1stfloor
		wm_announce "i'm 1stfloor"
		accum 3 set 0
	}

	trigger open_ground	//trigger to open doors at ground floor
	{
		trigger ground_left open
		trigger ground_right open
	}

	trigger close_ground	//trigger to close doors at ground floor
	{
		trigger ground_left close
		trigger ground_right close
	}

	trigger open_1stfloor	//trigger to open 1st floor
	{
		trigger 1stfloor_left open
		trigger 1stfloor_right open
	}

	trigger close_1stfloor	//trigger to close 1st floor
	{
		trigger 1stfloor_left close
		trigger 1stfloor_right close
	}
}

all the things that get called from this script part are just the gotomarker parts of the script_movers

the problematic part is the move_ground
i get the “not moving” announcement but it fails at accum 2 abort_if_not_equal 1 eventough it should be set to 1 because i moved the elevator up before

and the button stuff is just a special button that opens all doors, or closes the door where the elevator isn’t atm (it’s working (as long as the elevator is at ground level = accum 2 has not recived a new set value))

1 thing i get out of it, upper doors move when i press the button and the elevator is at 1st floor, therefore accum 2 has to be 0 not 1 because both get checked before doors get moved (accum 2 trigger_if_equal 0, accum 2 trigger_if_equal 1 …)

edit: never mind is just checked my code and rocogniced that i had deleted 1 line when starting to debug that did the accum 2 set 1 :rolleyes:


(C) #2

I did not have a good look at Your script,
but i see 1 thing at first glance…

trigger button_0
{
	wait 10		//wait that trigger button works
	accum 2 trigger_if_equal 0 elevator_move open_1stfloor
	accum 2 trigger_if_equal 1 elevator_move open_ground
	accum 1 set 1
}

That “accum 1 set 1” will never execute because of the wait-statements in elevator_move open_1stfloor and/or elevator_move open_ground.

After encounting a wait-statement in a trigger, that trigger will not return control to its caller…
The “GoSub”-flow is gone…


(merlin1991) #3

that part was working like a charm :smiley:

but the problem solved itself, i dunno why but well it works now :cool: