Help with event rotation

Arise

Veteran
Veteran
Joined
Aug 31, 2016
Messages
132
Reaction score
19
Primarily Uses
Hi!


I need some help.


I've added the mouse plugin, and it seems that I can click on some event and I can make it print the message in the javascript console.


So I know that clicking on the event works every time.


The event is using an actor image, and I set it up as a starting point looking down (the direction).


Now I want that every time I click on the event, it should turn in clock wise direction, first click to the left, second time to go facing up, third click it should go to right and fourth click it should return to the original position (that would be facing down).


The problem is it not working as it should, every click is registered in the console, but it always prints that is facing right over and over again. Also is not really rotating.


I managed to get it rotating if I move my actor around it, it moves only one time, but still can't say why this depends on the actor.


Please help, thanks!


My code is below...

◆Comment:click_activate!
◆Script:console.log("clicked");
◆If:This Event is facing Down
◆Script:console.log("clicked event=down");
◆Set Movement Route:This Event
: :◇Turn Left

:Else
◆If:This Event is facing Left
◆Script:console.log("clicked event=left");
◆Set Movement Route:This Event
: :◇Turn Up

:Else
◆If:This Event is facing Up
◆Script:console.log("clicked event=up");
◆Set Movement Route:This Event
: :◇Turn Right

:Else
◆If:This Event is facing Right
◆Script:console.log("clicked event=right");
◆Set Movement Route:This Event
: :◇Turn Down

:End

:End

:End

:End
◆Exit Event Processing













issue.png
 
Last edited by a moderator:

Celianna

Tileset artist
Veteran
Joined
Mar 1, 2012
Messages
10,557
Reaction score
5,592
First Language
Dutch
Primarily Uses
RMMV
There should be a much easier way to do this - MV already has mouse support by default, so you can click on the event without having to use any script options.


if you want the event to rotate in a specific order, then you can simply make several event pages. First event page is the event looking down and set to action button, in the contents turn self switch A on. Create a new event page with the condition set to self switch A is on, set the event image to right/left (whatever you want), action button as well, then turn self switch A off, and turn self switch B on. Create a new event page for self switch B etc.


Keep doing this until the final event page, where you turn off all self switches, and it should cycle back to the beginning.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
by default, all events turn into the direction of the player when activated - your mouse script doesn't change this, and it happens before the click is processed.


To prevent that, you need direction fix checked - which would also block turning.


Solution: check direction fix, but in the move route commands turn it off directly before the turn command and on again after that turn.
 

Dad3353

Veteran
Veteran
Joined
Mar 9, 2016
Messages
421
Reaction score
110
First Language
English
Primarily Uses
@Arise...


Try putting a 'Wait' command after each 'Set Movement Route', to give the system time to do the turn and 'forget' the mouse click..?


Be wary, too, of 'This Event'; it may pay to designate specifically the Event you wish to control (EV001 in your example...).


Just sayin'; hope this helps.
 
Last edited by a moderator:

Arise

Veteran
Veteran
Joined
Aug 31, 2016
Messages
132
Reaction score
19
Primarily Uses
Andar's solutions proved working miraculously, I still can't wrap my head around his explanation... :)


Last question for @Celianna: how should I do the clicking with the mouse on the tiles without using my Actor character? He is not going to move in order to interact with the event...


Final code is like:

Code:
◆Comment:click_activate!
◆Script:console.log("clicked");
◆If:This Event is facing Down
  ◆Set Movement Route:This Event (Wait)
  :                  :◇Direction Fix OFF
  ◆Set Movement Route:This Event (Wait)
  :                  :◇Turn Left
  ◆Set Movement Route:This Event (Wait)
  :                  :◇Direction Fix ON
  ◆
:Else
  ◆If:This Event is facing Left
    ◆Set Movement Route:This Event (Wait)
    :                  :◇Direction Fix OFF
    ◆Set Movement Route:This Event (Wait)
    :                  :◇Turn Up
    ◆Set Movement Route:This Event (Wait)
    :                  :◇Direction Fix ON
    ◆
  :Else
    ◆If:This Event is facing Up
      ◆Set Movement Route:This Event (Wait)
      :                  :◇Direction Fix OFF
      ◆Set Movement Route:This Event (Wait)
      :                  :◇Turn Right
      ◆Set Movement Route:This Event (Wait)
      :                  :◇Direction Fix ON
      ◆
    :Else
      ◆If:This Event is facing Right
        ◆Set Movement Route:This Event (Wait)
        :                  :◇Direction Fix OFF
        ◆Set Movement Route:This Event (Wait)
        :                  :◇Turn Down
        ◆Set Movement Route:This Event (Wait)
        :                  :◇Direction Fix ON
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:End
◆Exit Event Processing
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
@Arise no need to make three set move route commands for one move command each - you can combine all three commands (fix off, turn, fix on) into a single move route.
 

Arise

Veteran
Veteran
Joined
Aug 31, 2016
Messages
132
Reaction score
19
Primarily Uses
Thanks, you are right about move comand on same line!


Only thing is I'm new to this kind of "scripting" language and instead of moving around like a fish in the water I feel more like an elephant in a porcelain store. :)  


Hence the "amateurish" style of my writing code.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Then I suggest you follow the link to the starting point in my signature.


Yes, those tutorials will take time - but it is time very well spend, because you'll improve your development speed and experience a lot that way.


(and it's called eventing, not scripting, because scripting is changing the engines on an even deeper level (plugin writing)
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Question, if I do this in my own game, would I need to make all the ifs to check direction? Would a Turn 90º Right not work?
 

Arise

Veteran
Veteran
Joined
Aug 31, 2016
Messages
132
Reaction score
19
Primarily Uses
If you want to rotate in all four directions then yes, you need 4 ifs, if your starting location could be in any direction.


You dont really need 4 ifs, you need actually 3 ifs and an else, but all the ifs must be with an else clause also I think, unless you arrange them in order... because you dont want after one if condition to get triggered again by the next if condition.


What exactly is your concern with the above posted eventing code?
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Well, I was thinking about instead of putting the three ifs and turning in the next direction just putting to turn right 90 degrees.


Wouldn't that make it more efficient? Or does it not work like that with the mouse/touch?
 

Arise

Veteran
Veteran
Joined
Aug 31, 2016
Messages
132
Reaction score
19
Primarily Uses
Oh yes, it works just fine if you only want the animation. Code below for posterity.


The ifs are good only if you want to do extra actions/scripting based on the current position.

Code:
◆Comment:click_activate!
◆Set Movement Route:This Event (Wait)
:                  :◇Direction Fix OFF
:                  :◇Turn 90° Right
:                  :◇Direction Fix ON
◆Exit Event Processing
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top