Can anyone tell me whats wrong with this code?

Started by bx83, Mon 23/03/2020 22:17:18

Previous topic - Next topic

bx83

I have this code:
Code: ags

switch (player.Room) {
		1:  candleobjnum=3; break;
		2:  candleobjnum=7; break;
...
		55: candleobjnum=1; break;
		58: candleobjnum=-1; break;//no candlelight object
	}


I tells the system what object number the "CandeLight" object was for each room. (next time I'm using a GUI :/)

When I run, I get the error: "improper argument '1' for Switch statement." or something of the like.

What is wrong with this? I thought 'switch (result of numer operation) { .... }' was the *only* argument you could put in there anyway?

ManicMatt

I can't help you with that, but I do want to chime in that I needed an object to be animated from the global script, so instead I made the object a character.

Crimson Wizard

#2
You need to add "case" before each case value:
Code: ags

switch (player.Room) {
		case 1:  candleobjnum=3; break;
		case 2:  candleobjnum=7; break;


There are examples in the manual: https://www.adventuregamestudio.co.uk/manual/ags43.htm#switchstatement

bx83

Oh dear, I've done a bad thing :/
Sorry guys.

SMF spam blocked by CleanTalk