Event Name Changer

I found this but apparently it doesn't work

http://www.rpgmakervxace.net/topic/8346-change-event-name/

class Game_Event attr_accessor :name alias galv_event_name_initialize_name initialize def initialize(map_id, event) galv_event_name_initialize_name(map_id, event) @name = event.name endendI tried using this in script call

$game_map.events[3].name = "<Enemy13>"

and it doesn't work. Can someone help? Thank you ;D
And where are you using the name of the event? How do you know that it's not working?
I'm using the name of the event called within the same event that needed the name change. Let me try calling it from another event if it makes any difference.

To ur second question, I did this msgbox($game_map.events[3].name) and it came back with the same name and it was never changed XD

EDIT:

Nope it doesn't work =/
What you have changed, is the @name variable's value. Not the real event name.
What you have changed, is the @name variable's value. Not the real event name.
ohooooo... I knew that! LoL, juz kiddin no I didnt XD

Can we make one or is it impossible?
There are several problems with this approach, which is why usually no one tries to rename events.


1)


You want to change the name of an event (which has no function by default) because some other script reads the name and reacts to it.


But do you know WHEN the other script reads the name?


Consider this sequence:


- Map gets loaded


- <other script> checks event list and loads its data from there as part of the mapload function


- first event is executed, changing the name of one other event.


The name change will have no effect because the other script has already completed its check.


And you cannot change an event name before loading the map, because the event doesn't exist until the map is loaded.


2)


Maps are read-only, even if you change the name that change will be discarded when the player leaves the map.


For permanent changes, you'll need to store the new names in datafiles and load them on mapload - something that is a lot more complicated than the tiny script you have there.


For those and other reasons, it is usually a lot easier not to change the event name before the other scripts loads its data, but to change the other scripts data dierectly after it got loaded.


But that requires knowledge of the other script and different commands depending on what the other script is.
Depends on how you try to read the data, if you are accessing through the same @name variable, then what you did already changed the name if you tried to access @name again.
Daaang! That sounds more complicated than this

class Game_Event attr_accessor :name alias galv_event_name_initialize_name initialize def initialize(map_id, event) galv_event_name_initialize_name(map_id, event) @name = event.name endendI thought it would be just a line or too added, LoL guess not slim jim =/
What you did is load the event's name into @name Variable there.

So $game_map.events[x].name will return the name in the @name variable, not from the event.

And changing attr to accessor means you can change that value. @name not event's name.

But $game_map.events[x].name = "New Name" should work.

Simply put it into a game variable and print it out in the message box after the change and you should be able to see it working.

If you are trying to make this works with another script, you will need to point that script to this new @name value to make it work.
U mean like so Meow

Code:
class Game_Event  accessor :name      #attr_accessor :name  alias galv_event_name_initialize_name initialize  def initialize(map_id, event)    galv_event_name_initialize_name(map_id, event)    @name = event.name  endend
Maybe this will work. Couldn't really test it now:

Code:
class Game_Event  alias galv_event_name_initialize_name initialize  def initialize(map_id, event)    galv_event_name_initialize_name(map_id, event)    @the_event = event  end  def name    if @the_event.nil?      ''    else      @the_event.name    end  end  def name=(value)    @the_event.name = value unless @the_event.nil?  endend
No i mean that script is working if you are reading the name through @name.

[1] Put that original script in your top post in your script editor.

[2] In the game, create an event and make a Control Variable [1]

[3] Put $game_map.events[1].name in the script box of Control Variable

[4] Make a message to show \v[1]

--------- Thus far you get your event 1 name.

[5] Make a script call and put $game_map.events[1].name = "apple"

[6] repeat [3] & [4] and you should get the result "apple" in the message box.

That means, the script works. but using a new variable for read/write. If you try to use another script with this snippet, you will need to point that script to read this new @name variable instead of getting the event names by their own method.

@Hudell

That's the same as putting up a new variable for name. To change an event's actual name, we will need to tap into the RPG::EVENT class.
Has anyone read my post above?


As long as the OP/requester doesn't post a link to the script where the event name is used, we can't even tell if the rename will work for that other script, even if you get it to work in itself...


I think it's better to wait for that link before putting too much work into bughunting...
To change an event's actual name, we will need to tap into the RPG class
Yeah, thats what I actually need XD

EDIT:

I cant find the darn link LoL, so I'm just gonna have to post this script here to get a general idea why I need the name changer

Spoiler
# =============================================================================# TheoAllen - Events Name

# Version : 1.0

# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com

# (This script documentation is written in informal indonesian language)

# =============================================================================

($imported ||= {})[:Theo_TextEvent] = true

# =============================================================================

# CHANGE LOGS:

# -----------------------------------------------------------------------------

# 2013.06.09 - Finished script

# =============================================================================

=begin

Perkenalan :

Script ini cuman nampilin text diatas event

Cara penggunaan :

Pasang dibawah material namun diatas main

Tulis pada nama event jika mau ditampilin

TERMS OF USE :

Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih

keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau

dipake buat komersil, jangan lupa, gw dibagi gratisannya.

=end

# =============================================================================

# Konfigurasi kecil2an :

# =============================================================================

module THEO

module MAP

# Lebar window yg diisi text

WINDOW_WIDTH = 200

# Size font

FONT_SIZE = 17

# Warnanya (red,green,blue

FONT_COLOR = Color.new(255,255,255)

# Posisi offset dari koordinat y

OFFSET_Y = 0

end

end

# =============================================================================

# Batas konfigurasi

# =============================================================================

module THEO

module MAP

module REGEXP

TEXT = /<(?:TEXT|text) 🙁 .*)>/i

end

end

end

class Window_CharText < Window_Base

include THEO::MAP

def initialize(char,text)

@char = char

@text = text

super(0,0,window_width,window_height)

self.opacity = 0

contents.font.size = FONT_SIZE

update_placement

refresh

end

def update_placement

return unless @char

self.x = @char.screen_x - self.width/2

self.y = @char.screen_y - 20 - self.height - OFFSET_Y

end

def update

super

update_placement

end

def refresh

contents.clear

draw_text(0,0,contents.width,FONT_SIZE,@text,1)

end

def window_width

WINDOW_WIDTH

end

def window_height

return FONT_SIZE + standard_padding*2

end

end

class Game_Event < Game_Character

def name

@event.name

end

end

class Scene_Map < Scene_Base

include THEO::MAP

alias pre_text_over_event_start start

def start

pre_text_over_event_start

create_text_event_windows

end

def create_text_event_windows

@event_text_windows = []

$game_map.events.values.each do |event|

case event.name

when REGEXP::TEXT

text = $1.to_s

@event_text_windows.push(Window_CharText.new(event,text))

end

end

end

alias pre_update_window_text update

def update

pre_update_window_text

update_text_window

end

def update_text_window

@event_text_windows.each {|w| w.update}

end

alias pre_text_event_terminate terminate

def termminate

pre_text_event_terminate

dispose_text_event_windows

end

def dispose_text_event_windows

@event_text_windows.each {|w| w.dispose}

end

alias text_event_post_transfer post_transfer

def post_transfer

dispose_text_event_windows

create_text_event_windows

text_event_post_transfer

end

end
What Andar said is correct on the reset part, if you didn't store the name in a new variable that won't get reset every map loading, whenever the player leave the map and return, everything is back to original, even if we rewrite RPG::EVENT.name
@Hudell

That's the same as putting up a new variable for name. To change an event's actual name, we will need to tap into the RPG::EVENT class.
I assumed that the event parameter was the RPG::EVENT instance.
What Andar said is correct on the reset part, if you didn't store the name in a new variable that won't get reset every map loading, whenever the player leave the map and return, everything is back to original, even if we rewrite RPG::EVENT.name
Dang! And I was planning of having every event with a name. So, if I store every name into this one variable, thats alot of work combining all the event names LoL daaaaaamit!

Edit:

And I'm planning to have well over 500 events O_O my goodness, the finger work slave!
 

I assumed that the event parameter was the RPG::EVENT instance.
RPG::EVENT is included in RPG::MAP so what you assumed is correct.

But @the_event = event is declaring a new variable @the_event

and @the_event.name reads/writes from/to @the_event

Dang! And I was planning of having every event with a name. So, if I store every name into this one variable, thats alot of work combining all the event names LoL daaaaaamit!

Edit:

And I'm planning to have well over 500 events O_O my goodness, the finger work slave!
Wish you best of luck on your project! 😉
I suppose you want the Schala Battle System to respond to the events new name?

In this case, it's just as Andar mentioned: the feature is designed to work with the events editor name, it won't work correctly when you change the events name during runtime.

If you want to transform an existing enemy event into another one, you could probably use

$game_map.events[3].battler.transform( New Enemy ID )

to change the enemies stats into those of the new enemy.

(Won't work if the target event is not flagged as an enemy)

Edit: Referring to: link
I suppose you want the Schala Battle System to respond to the events new name?

In this case, it's just as Andar mentioned: the feature is designed to work with the events editor name, it won't work correctly when you change the events name during play.
Well, didnt really plan on putting names on enemies but just for like events so it shouldn't make any incompatibilities and plus schala refers to event IDs I believe? I thought event names werent used for anything but just a name while everything else is referred to as the event IDs?

Original thread: https://forums.rpgmakerweb.com/threads/event-name-changer.45285/