Moving spike events throwing error message.

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have some moving spikes which, if the player touches them when the spikes are up, will call a common event.  Here is a screenie of the event page with that call.



You are unable to see the full script call in the shot.  It is this:

$game_player.x == $game_map.events[event_id].x && $game_player.y == $game_map.events[event_id].y

The event page is set to parallel process because otherwise if the player is standing on the tile when the spikes come up, the call to the common event is not triggered.  Page one only contains the other half of the up and down movement of the spike (both bits are contained within the custom movement).

The common event which is called is this:



When the player enters the map, even before the transfer fadein has happened, the following error message comes up:

Scrip 'Game_Interpreter' line 450: NoMethodError occurred

undefined method 'x' for nil:NilClass

Line 450 is about evaluating param 1 - which is HP.  But nothing here is asking anything about HP.  I therefore have no idea what could be wrong.

Any help would be much appreciated.

Thank you.

EDIT

If I start a New Game on this map, which is what I did for testing purposes, there is no problem.  The error message only occurs if I transfer to the map from somewhere else.
 
Last edited by a moderator:

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
It seems like the x is not a method, of the class it refers to.

means that

either 

game_player.x  

or 

game_map.events[event_id].x

is not a valid syntax.

I am not fluent in Ruby but that is what the error seems to me.

Edit:

Does game_player has an x ttribute  that you can refer to via a method or directly?

Can the event have the x? game_map.events 

 

Why don't you use two Conditinal Branches one into another to achieve the same thing instead?

I know this line is better and neat thing to do, but... you know... it's more simple that way.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
game_player.x is a term which occurs in several scripts, so I am fully confident that that is correct.

The second part, i.e. $game_map.events[event_id].x was given to me (as was the whole of that script call) from over on the script call support board.  The original suggestion was:

$game_player.x == $game_map.events[id].x && $game_player.y == $game_map.events[id].y

and Iavra confirmed that for the [id] part, one  can use "event_id" to use the current event's id.  So that seems to confirm both uses of x (I think).
 

_Shadow_

Tech Magician Level:
Moderator
Joined
Mar 2, 2014
Messages
4,078
Reaction score
2,654
First Language
Greek
Primarily Uses
RMMZ
and Iavra confirmed that for the [id] part, one  can use "event_id" to use the current event's id.  So that seems to confirm both uses of x (I think).
Not sure, as I said I am not fluent yet but you must confirm if you can make a reference like $game_map.events[id].by default.

This might cause you the trouble along of course with the y reference if that's the case.

You might need to override the class constructor first or a method. I don't know...

Edit:

Asked a wizard to take a look at this.

She will probably be here soon to help you out.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I think I must be able to make a reference like $game_map.events[id].x by default because if I couldn't, then these spikes would not work when I tested them in a 'New Game'.  But they do work.  If I stand on one, or touch one when the spikes are up, I am knocked back to the beginning.
 

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
346
Primarily Uses
My gut feeling here is that somehow the parallel process is trying to run before the map has actually loaded and therefore $game_map.events[id] has not been loaded and does not exist yet. The previous map had less events and therefore the event in question did not exist. An ugly fix might be to see if the event exists and abort the event if that is not the case. Let me do a few quick tests.


Actually, I can't even replicate the error in a brand new project. I copied the events shown (minus clear path since I don't have the associated script), and I had no issues. Are there any other common events or parallel processes that might be active on the map? Or perhaps the map you transferred from? Have you tried transferring from a different map to see if it still crashes?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Try using @event_id instead of event_id
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Yato

Sorry for not replying - edits don't come up as new, so I didn't realize that you had added to your post.

I have a lot of these spikes on that map.  They are in two blocks, the second of which is not activated until you are about halfway round.  I tried making the first page of the spikes in the first block conditioned by a switch which I would activate a few steps into the map.  Trying that with the player there as New Game showed that they were indeed inactive until I walked across those tiles.  However, transferring in from another map I still got the error message.  I have now completely deleted that first block and intend to start again, if I can find a sollution.#

@Shaz

I try changing them all to @event_id and it seemed to make no difference.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Can you attach the map that this event is on?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Do you mean post a screen shot?  I don't follow what you mean by 'attach' in this context.  sorry to be so obtuse, I'm getting tired.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I meant attach the map, or send it to me so I can look at your event.


Have you tried to create a new project and copy/paste the event, as-is, into that project? It could be something with your scripts.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I'm not sure that the map on its own will work because there are no default tiles so you'd just have a blank map, and it relies on a range of switches to work.

I've tried in a new project with one event and it's fine - but then it's also fine in my own project if I start on that map.  It is when i transfer into it that I have problems.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Are you sure it's THAT event that's causing the crash? Add a new page to it with default settings (no conditions, no change to trigger, no event commands) and run again - see if it still happens. If it does, you're looking for another event.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have no way of knowing which event it is.  There are about 40 or so in this block, in 3 groups, because the spikes are going up and down at different speeds in separate rows.  

The second block of events are identical - they are copy/pasted from those in the first block, and just arranged in a different pattern on the map.  The only thing that is different about them is that they are not active when you enter the map.  They are activated by a switch when you are part way round.

I tried adding a switch to the first page of the events in the first block which would mean that they too were not active when I entered the map, but it didn't seem to make any difference.  I think I am now too tired to try anything else tonight.  Maybe tomorrow will bring enlightenment.

Thanks for your suggestions.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Send me your map. It doesn't matter if I don't have the tileset.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
I copied your condition as-is and it works fine for me. Note that you don't need to set the variables beforehand, since you are accessing player x and y directly.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Thanks for the confirmation that the events themselves are okay.  Also thanks for the info about the variables. That will save me time in the future.

As far as I can see, it looks like it's a problem with the Effectus script, though I can't be sure until I get a reply from Source.

In the meantime, I'm leaving this thread open in case someone has a brainwave.

EDIT

It was that script and Source has given me a fix, so all is well.

Thank you to all those who contributed to the thinking on this.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,584
Latest member
Faustus2501
Top