rpgtkoolmv / corescript

http://www.rpgmakerweb.com/products/programs/rpg-maker-mv
MIT License
311 stars 75 forks source link

"$this." or "$self." self reference for events. The current way is very counter intuitive even for programmers #188

Open blurymind opened 5 years ago

blurymind commented 5 years ago

Right now when you use the editor, and you want to access a variable of an event from the event you are editing, the syntax is very counter intuitive and very long. Like this: $dataMap.events[n].name Where you have to also know how to get the event's own ID ('n') (I already forgot it)

This is counter intuitive - even for programmers. When you try: $this.name you find out that $this is not even defined. The event has no reference to itself!

Consider having to check an event's own variable from an addon via a conditional branch - only way to do it is by using the 'script' option. The syntax to access variables is a pain in the butt and is easy to forget. Even if you know javascript, you have to dig through forums to find out this very basic thing..

Suggested solution: Define $this automatically when calling events from the editor, so when using $this.x for example, we can get the event's X , without having to write tons of obscure functions just to get the event to look into its own script values

krmbn0576 commented 5 years ago

use this.character(0) ;-)

blurymind commented 5 years ago

@krmbn0576 does this.character(0) make the event to refer to itself? is 0 the event tab's index?

Its still not very intuitive :) who is character 0 ?

Why not this.event..

krmbn0576 commented 5 years ago

does this.character(0) make the event to refer to itself?

Yes. 0 means itself 😇

blurymind commented 5 years ago

@krmbn0576 what would 1 mean in this case then? :)

krmbn0576 commented 5 years ago

this.character(1) means the event of Id:1.

0 is special

blurymind commented 5 years ago

@krmbn0576 the method is hard to discover :)

Rpg maker MV has no official API documentation. There is one incomplete google doc made by the community and even that is hard to find

krmbn0576 commented 5 years ago

Thanks, I'll think about it.

Inkognitoo commented 4 years ago

https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/edit#gid=0

I think you can just take it and make official