The RPG Maker Resource Kit

Other Game Creation => Program Troubleshooting => Topic started by: CursedBlackWolf on November 29, 2009, 07:05:03 PM

Title: (Resolved) Activating an event through a script
Post by: CursedBlackWolf on November 29, 2009, 07:05:03 PM
I'm having a bit of a problem with a script I'm working on. I'm trying to make it so that a specific switch is turned on when a selection is made from a custom menu script, thereby activating an event on the current map. The problem is that the event does not start until you leave the current map, and come back to it.

Here's the script lines used:
[spoiler]    if Input.trigger?(Input::C)
     case @command_window.index
       when 0 # City upgrades
         if $game_variables[3] < $game_variables[43] and $game_variables[4] < $game_variables[44]
           $game_system.se_play($data_system.cancel_se)
         end
         if $game_variables[3] >= $game_variables[43] and $game_variables[4] >= $game_variables[44]
           $game_system.se_play($data_system.decision_se)
           $game_variables[5] = ($game_variables[5] + 1 )
           $game_variables[3] = ($game_variables[3] - $game_variables[43])
           $game_variables[4] = ($game_variables[4] - $game_variables[44])
           $game_switches[11] = true
           $scene = Scene_Map.new
         end[/spoiler]

And here's the event page that is supposed to activate:
[spoiler](https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg215.imageshack.us%2Fimg215%2F7922%2Feventv.th.jpg&hash=728a207c590c6ed4d26224b7a78caf325a99c94e) (http://img215.imageshack.us/i/eventv.jpg/)
[/spoiler]

As I said, the event doesn't start unless you leave the map and return to it, and I can't figure out how to change that.
Title: Re: [RMXP] Activating an event through a script
Post by: modern algebra on November 29, 2009, 07:23:00 PM
What are the triggers for that event? Is it parallel process with a switch condition? Is it the last page in the event?
Title: Re: [RMXP] Activating an event through a script
Post by: shaz on November 29, 2009, 09:10:39 PM
You don't have another page on that event that's run when the switch is off, that erases the event, do you?
Title: Re: [RMXP] Activating an event through a script
Post by: CursedBlackWolf on November 29, 2009, 11:32:18 PM
Quote from: shaz on November 29, 2009, 09:10:39 PM
You don't have another page on that event that's run when the switch is off, that erases the event, do you?

I do not. It's the last page of the event. The first page is completely blank.

Quote from: modern algebra on November 29, 2009, 07:23:00 PM
What are the triggers for that event? Is it parallel process with a switch condition? Is it the last page in the event?

It's on Auto run with a switch condition, and it's the last page of the event.
Title: Re: [RMXP] Activating an event through a script
Post by: modern algebra on November 30, 2009, 12:09:24 AM
DO any of the pages in the event include the "Erase Event" command?
Title: Re: [RMXP] Activating an event through a script
Post by: CursedBlackWolf on November 30, 2009, 12:38:57 AM
Quote from: modern algebra on November 30, 2009, 12:09:24 AM
DO any of the pages in the event include the "Erase Event" command?

They do not.
Title: Re: [RMXP] Activating an event through a script
Post by: Zeriab on November 30, 2009, 01:25:41 AM
If I remember correctly then you need to tell the game_map that it needs to refresh:
$game_map.need_refresh = true
Title: Re: [RMXP] Activating an event through a script
Post by: shaz on November 30, 2009, 04:02:20 AM
Hey, that's what I was going to say next ;)
Title: Re: [RMXP] Activating an event through a script ( Resolved )
Post by: CursedBlackWolf on November 30, 2009, 05:52:17 AM
You guys are awesome!

I figured it had something to do with refreshing the map, I just didn't know the correct code. Thanks!

Quote from: ???ï?? on November 30, 2009, 01:25:41 AM
If I remember correctly then you need to tell the game_map that it needs to refresh:
$game_map.need_refresh = true

Worked like a charm!