a spell to light the stars

So, I have a problem which I'm guessing is not unique. I'm sure it's been fixed before, but I can't find anyone posting tutorials. The only caveat, before I get into the problem, is that I'd like to avoid scripts and plugins if at all possible.

In the game I'm making, the main characters are going around relighting dimming "Stars." Now, I understand I could just have the stars be an event that changes them to lit stars rather than dim and this would do what I want. Because of a certain aesthetic, however, I'd like to be able to have one of the characters cast a menu only spell that has the effect of triggering an event (the star lighting up). It needs to light up ONLY the star right in front of the party, not all of them in the game. Is there a way to do this, or do I need to just make a normal event and give up on the localized spell idea?
You can do this with a common event. Have the spell call a common event. If you don't want to use a script command, it'll be a little bit more involved.

You need to assign the player's X and Y coordinates to variables; you can do this with the "get location info" command. Then you need to have a conditional branch which checks which direction the player is facing and then subtract/add to the X/Y accordingly. Then you'd have one line of script which turns on self switch A of the event that's on those coordinates. The call would be something like

const events = $gameMap.eventsXy($gameVariables.value(id of x var), $gameVariables.value(id of y var)
if (events.length > 0) {
const event = events[0];
$gameSelfSwitches.setValue([this.mapId(), event.eventId(), 'A'], true)
}

Then you'd just have a second page on each star event activated by self switch A which has the "lit" graphic.
you can split it in two parts.
if the event is touching the player, you can set it to send itself to a variable, and then the skill will go light "whomever this variable is"
You can do this with a common event. Have the spell call a common event. If you don't want to use a script command, it'll be a little bit more involved.

You need to assign the player's X and Y coordinates to variables; you can do this with the "get location info" command. Then you need to have a conditional branch which checks which direction the player is facing and then subtract/add to the X/Y accordingly. Then you'd have one line of script which turns on self switch A of the event that's on those coordinates. The call would be something like

const events = $gameMap.eventsXy($gameVariables.value(id of x var), $gameVariables.value(id of y var)
if (events.length > 0) {
const event = events[0];
$gameSelfSwitches.setValue([this.mapId(), event.eventId(), 'A'], true)
}

Then you'd just have a second page on each star event activated by self switch A which has the "lit" graphic.
It looks a bit complicated, but doable! I'll work on that sometime this weekend, probably. Monday at the latest (I work weekends). I'll post whether it works as intended.
It looks a bit complicated, but doable! I'll work on that sometime this weekend, probably. Monday at the latest (I work weekends). I'll post whether it works as intended.
If you update when you try it I'll help you figure out any issues.
you can split it in two parts.
if the event is touching the player, you can set it to send itself to a variable, and then the skill will go light "whomever this variable is"
The problem with this is that the spell only activates common events. As far as I can tell, unless I want to use a different spell for each star (which I don't), the spell will either light them all or only one.
have the common event read the variable, and grab that event from the map.
it's called "pointer"

the *action* is always the same: light the star.
the star in this case is an event, which you can set to have two pages, one lit, one unlit. (or not even that! you can just set the common event, "the handler", to simply change an event's graphic, starting from all unlit)
which event is to be lit? -> whichever the pointer points to.

I learned about those terms while working with Python: handler, trigger, condition, action, pointer, etc.
a pointer tells you where to direct the action, that a handler sends, when a trigger fires, when a condition validates.
usually you can pack the condition along with the handler in the same block running in parallel, always listening.
have the common event read the variable, and grab that event from the map.
it's called "pointer"

the *action* is always the same: light the star.
the star in this case is an event, which you can set to have two pages, one lit, one unlit. (or not even that! you can just set the common event, "the handler", to simply change an event's graphic, starting from all unlit)
which event is to be lit? -> whichever the pointer points to.
The problem with that is that unless you surround the event with other events which clear out the pointer variable, using the skill after "touching" a star and walking away from it will light the last one you touched even if you're no longer next to it.
The problem with that is that unless you surround the event with other events which clear out the pointer variable, using the skill after "touching" a star and walking away from it will light the last one you touched even if you're no longer next to it.
already considered, but I didn't want to go there unless the concept was understood.
I was thinking of running that touch in parallel, so if var = "me", no change, if var != "me" -> var = "me".
upon loss of contact, reset.
That's a viable approach, but I think in this case it makes most sense to just do the event check when the spell is used rather than checking it every frame.
Sorry about the delay in replies. Reading these posts certainly shows me that I still have a lot to learn. I'm quite lost right now. The other problem which has arisen is that I'm not sure how to test if the script mentioned will work without finishing at least the next dungeon.
@gstv87 could you try explaining the concept baring in the mind that I know virtually no programming or scripting? The most programming I've ever done was playing around with Basic in highschool. That was 20 years ago, and even then I was never especially skilled at it.
Sorry about the delay in replies. Reading these posts certainly shows me that I still have a lot to learn. I'm quite lost right now. The other problem which has arisen is that I'm not sure how to test if the script mentioned will work without finishing at least the next dungeon.
@gstv87 could you try explaining the concept baring in the mind that I know virtually no programming or scripting? The most programming I've ever done was playing around with Basic in highschool. That was 20 years ago, and even then I was never especially skilled at it.
How far did you get in trying to make the common event I talked about?
You can do this with a common event. Have the spell call a common event. If you don't want to use a script command, it'll be a little bit more involved.

You need to assign the player's X and Y coordinates to variables; you can do this with the "get location info" command. Then you need to have a conditional branch which checks which direction the player is facing and then subtract/add to the X/Y accordingly. Then you'd have one line of script which turns on self switch A of the event that's on those coordinates. The call would be something like

const events = $gameMap.eventsXy($gameVariables.value(id of x var), $gameVariables.value(id of y var)
if (events.length > 0) {
const event = events[0];
$gameSelfSwitches.setValue([this.mapId(), event.eventId(), 'A'], true)
}

Then you'd just have a second page on each star event activated by self switch A which has the "lit" graphic.
So... I thought I understood when I read this the first time. Now I feel a little out of my depth. I honestly feel like maybe there's some information I'm supposed to know that I haven't learned. Is there, by chance, a link to a tutorial video that covers similar situations to the "get location info" command and its uses?
If you check Andar's signature there are some good basic tutorials there for learning the fundamentals of event commands and whatnot.
@Aslanemperor this will require some scripting knowledge, as I don't know the code from memory, only the structure.

on one hand you need the handler: the common event that'll do the thing.
that will be a single "change self switch" instruction in code form, OR, a single "set move route" instruction in code form.
both should be one or two instructions long, and you can use the script snippet to call that instruction from the interpreter, because you need to inject the target of that call by hand.
with that, you set that as the effect of the skill and *it* will have it's own validation, so the skill will be a direct use, like an item.

on the other hand, you need the pointer: the event that'll put itself as the target of the skill.
you do that by setting the event to have 3 pages: one standby, one running, and one lit.
once you light it, it'll be disabled and won't switch back.
when on standby, it'll wait to be triggered, and once triggered it'll start running.
to switch from one page to the other you use self-switches.
while running, it'll check the player's position respect to itself and if the player moves away, it'll reset and go back to standby (you can probably use the same common event as the handler, using a conditional: one branch will catch the call by the event and the other by the skill, but that depends on the final performance)

when you walk up to the event, it'll go into update automatically (player touch trigger).
while on update, it'll put itself on record, and watch the player.
if the player moves away, it'll remove itself from record, and go back to standby.
if the player remains on touch with the event and triggers the skill, the skill will call the common event, the common event will read the record, and do one of two things:
-enable a self switch on that recorded event (manually, via code), or
-change the event's graphic, through a move route command.
either way, the update loop will pick up one of those changes and stop.
you can then duplicate the events over the map, and they'll all always upload themselves to, and erase, the same memory slot.

me, I'd eyeball it and make it work as I go, having the structure and the functionality in my head.
I couldn't give you a detailed plan as I don't know exactly how it should be laid out.
I know it what it requires, just not which variant of the many available to use.
@Aslanemperor this will require some scripting knowledge, as I don't know the code from memory, only the structure.

on one hand you need the handler: the common event that'll do the thing.
that will be a single "change self switch" instruction in code form, OR, a single "set move route" instruction in code form.
both should be one or two instructions long, and you can use the script snippet to call that instruction from the interpreter, because you need to inject the target of that call by hand.
with that, you set that as the effect of the skill and *it* will have it's own validation, so the skill will be a direct use, like an item.

on the other hand, you need the pointer: the event that'll put itself as the target of the skill.
you do that by setting the event to have 3 pages: one standby, one running, and one lit.
once you light it, it'll be disabled and won't switch back.
when on standby, it'll wait to be triggered, and once triggered it'll start running.
to switch from one page to the other you use self-switches.
while running, it'll check the player's position respect to itself and if the player moves away, it'll reset and go back to standby (you can probably use the same common event as the handler, using a conditional: one branch will catch the call by the event and the other by the skill, but that depends on the final performance)

when you walk up to the event, it'll go into update automatically (player touch trigger).
while on update, it'll put itself on record, and watch the player.
if the player moves away, it'll remove itself from record, and go back to standby.
if the player remains on touch with the event and triggers the skill, the skill will call the common event, the common event will read the record, and do one of two things:
-enable a self switch on that recorded event (manually, via code), or
-change the event's graphic, through a move route command.
either way, the update loop will pick up one of those changes and stop.
you can then duplicate the events over the map, and they'll all always upload themselves to, and erase, the same memory slot.

me, I'd eyeball it and make it work as I go, having the structure and the functionality in my head.
I couldn't give you a detailed plan as I don't know exactly how it should be laid out.
I know it what it requires, just not which variant of the many available to use.
Alright. Please forgive me if I'm misunderstanding something, I'm going to try to boil it down, and if I've got something wrong, hopefully one of you can correct me:

As I'm understanding, you're effectively setting up self switches on each event with a script that constantly checks for if the player is standing facing the event. If they are and they use the spell, the event page that's on autorun will be triggered by the common event, activating the self switch.

What I'm wondering is: Will this work on more than one map? There are 5 Stars in 5 different dungeons (effectively, they're the goals of the dungeons.) Maybe I'm misreading, but it kinda sounded like it would only work on the one map. Technically, if push comes to shove, I can just make each Star an event at player touch and have the player go through a scene in which they "light" the star. I could even have a spell that does nothing but sit there on the screen with flavor text. That being said, I'm really wanting to make myself push through and do this, mainly because it really feels like if I can accomplish it, I'll have one more tool in my chest with which to make fun games!

Also, I really appreciate both of you helping so much with this! I thought I was asking for something simple and now I'm basically getting a crash course in basic scripting! Thank you so much!
a script that constantly checks for if the player is standing facing the event
if the player is not facing the event, the event will automatically reset.
not by a check *I* do, but by a check the program does, by default.

if they are and they use the spell, the event page that's on autorun will be triggered by the common event, activating the self switch.
no.
by using the spell, the common event will either change the event's page via a self switch (no *autorun* to speak of, because the self switch *condition* takes precedence), OR, change the event's graphic alone, which the internal loop will check for, to reset itself.
that's one of the alternatives you could have: integrate everything in one condition, either at the common event, or at the event itself.
the back-and-forth between event and common event must always happen either way, but should the need arise, you can add an extra check to either block without much consequence, and kill two birds with one stone.

Will this work on more than one map?
most definitely.
since events are map-dependent, and you can only run one map at a time, the relation is always Map/Event, regardless of either.
the common event will always go look for "this event" in the present environment that is always "this map".
"That other event that just underwent the same process on that other map over there" is always outside of the scope of the common event.
the only instance where you refer to the event directly by it's true identity, is by using the instruction to change a self switch (which, must be a 'manual override' because it doesn't usually work that way).
if you use a move route or a graphic change, you're always working on the map you're currently at.
that's why common events exist: to be shared across maps.
if the player is not facing the event, the event will automatically reset.
not by a check *I* do, but by a check the program does, by default.


no.
by using the spell, the common event will either change the event's page via a self switch (no *autorun* to speak of, because the self switch *condition* takes precedence), OR, change the event's graphic alone, which the internal loop will check for, to reset itself.
that's one of the alternatives you could have: integrate everything in one condition, either at the common event, or at the event itself.
the back-and-forth between event and common event must always happen either way, but should the need arise, you can add an extra check to either block without much consequence, and kill two birds with one stone.


most definitely.
since events are map-dependent, and you can only run one map at a time, the relation is always Map/Event, regardless of either.
the common event will always go look for "this event" in the present environment that is always "this map".
"That other event that just underwent the same process on that other map over there" is always outside of the scope of the common event.
the only instance where you refer to the event directly by it's true identity, is by using the instruction to change a self switch (which, must be a 'manual override' because it doesn't usually work that way).
if you use a move route or a graphic change, you're always working on the map you're currently at.
that's why common events exist: to be shared across maps.
Ok! I'm working on database stuff tonight because the second dungeon requires a key item to be created. While there I'll work on the script. As far as testing goes, I hope to have finished the second dungeon, skills, most (if not all) items, and the implementation of this script, followed closely by the test run of the game up to that point to make certain that it doesn't implode when I try to use it because I screwed something up. Also, going over the "How to use a script" tutorial and hoping that it helps to make me a little less clueless regarding this.
Here's hoping I don't need any other scripts or plugins to make this game work!

Original thread: https://forums.rpgmakerweb.com/threads/a-spell-to-light-the-stars.138039/