Syntax Error for simple script: $game_self_switches

Status
Not open for further replies.

Roish

Warper
Member
Joined
Jul 25, 2015
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Hey All,

I'm getting a syntax error for running some script in an event:



The script is:

$game_self_switches[[@map_id,1,'A']] = true

 

I thought this was pretty straightforward.. I'm trying to get the current event ("Door1" or EV002) to force EV001 (who's within the same map) to turn its self switch "A" on. I tried it with the literal map ID, too (MAP005), but no luck.

 

I must be missing something really simple-- according to what i've read, this is seems like the right script and setup..

 

I'm using RPG maker XP

 

PS. I know plain variables would work here, too, etc. There's probably a lot better ways of doing this, but right now I'm more worried about the script and why I'm wrong here  >:

 

 

Sorry if this is a n00b thing; Thanks for the help!! 8)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,057
Reaction score
13,685
First Language
English
Primarily Uses
RMMV
yeah - it is straightforward, and it's a simple error, and not your fault :) The editor adds auto line breaks, but in the wrong spot. For some reason, the script reads the first line and tries to process it, without putting the contents of the second line with it.

Put it like this:

Code:
$game_self_switches[[@map_id, 1, 'A']] = true
forcing the [[ to be at the end of the line tells it there's something still to come, so it goes looking for it rather than treating it as an additional command.
 
Last edited by a moderator:

Roish

Warper
Member
Joined
Jul 25, 2015
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Thanks Shaz!
That gets rid of the Syntax Error, but..

The target event still doesn't change. I'm pretty sure I'm targeting the right event. Do I need to force it to update? 

'Much appreciated   .-.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,255
Reaction score
7,632
First Language
German
Primarily Uses
RMMV
Please show screenshots of the event you want to change with that command. Basically that event needs to be set to react to the self-switch, and if you did something wrong no script command will help.

And one tip: use [alt]-[PrtScr] instead of only [PrtScr] to limit the screenshot to the active window
 

Roish

Warper
Member
Joined
Jul 25, 2015
Messages
4
Reaction score
0
First Language
English
Primarily Uses


--Bam! I'm trying to get the door(EV001) to change through its selfswitch instead of a variable switch or something, but EV002(Otherside) is the event that's actually handling the events, and thus has the "$game_self_switches..." script in it.

I'm wondering if it's an update or debug problem, because the script works if I put in an unrelated variable change in there:



Here I just made up the ControlSwitch "DoorUpdater" variable. Sticking it on the end of the script seems to make the self switches work as planned...

Technically I can get things to function-- I'm just wondering why it doesn't work by itself.

Also, It's dumb but I never knew about the [Alt]-[PrtSc] thing, haha  8)

Thanks!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,057
Reaction score
13,685
First Language
English
Primarily Uses
RMMV
After the $game_self_switches, try adding a line that says $game_map.need_refresh = true


This SHOULD already be done simply by changing the self switch. Let us know if it makes a difference.
 

Roish

Warper
Member
Joined
Jul 25, 2015
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Sweet!

It did make a difference. Things seem to function as intended now.

'Many thanks Shaz!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,057
Reaction score
13,685
First Language
English
Primarily Uses
RMMV
Very strange. It should have done that all along - and in fact it DOES do that when I use script calls in my game.


Ah, there you go. In XP it doesn't do the update. It was lucky that the command I gave you from Ace was the same :D


Here's what's going on ...


In XP, the Interpreter class takes care of setting the $game_map.need_refresh flag to true when you do Control Switches, Control Variables, or Control Self Switch. Because you're doing it in a script call, that line in the interpreter isn't being run.


Here's something you can do (and what they did in Ace, and maybe VX as well, when the shortcoming was discovered) that will mean you won't have to add this command every time you change a variable, switch or self switch by a script call:


In your script, find the Game_Switches, Game_Variables and Game_Self_Switches classes. Within each one, in the []= method, straight after the assignment (@data[switch_id] = value, $data[variable_id] = value and @data[key] = value), add a new line with $game_map.need_refresh = true. That means no matter how you assign the value to the switch, variable or self switch, the map will be updated.
 
Last edited by a moderator:

solar_sun76

Warper
Member
Joined
Feb 9, 2019
Messages
4
Reaction score
0
First Language
english
Primarily Uses
RMVXA
anyone here up to help me im trying to add u in fog through unpro's advaced tutorial but keep gettin same error message
upload_2019-4-27_1-57-16.png
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,496
Reaction score
5,330
First Language
english
Primarily Uses
RMMZ

@solar_sun76 , please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.


If you need help with something, please make your own thread in the appropriate section.

Closing.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

YES! officially released my games soundtrack on Itunes, Spotify, and Amazon..... kinda cool!

Another old age version of Reid. Trying out different style.
Hey everyone! Not sure how many people know about Cafofo Music on Itch.io, but I highly recommend their Sound Effects! It is amazing quality AND quantity and best of all, they are having a 50% sale! I can't express how much I love sales.
Wow.... My last map GIF got 47 likes, 16 retweet and 2,105 views on Twitter in 24 hours. My game thread here's only got 3k views in 6-7 months. I guess building my Twitter was insanely worth it. :LZSexcite:

Forum statistics

Threads
105,594
Messages
1,014,882
Members
137,264
Latest member
ZeoValinferno
Top