Status
Not open for further replies.
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,602
Reaction score
3,831
First Language
Java's Crypt
Primarily Uses
RMMZ
And where are you using the name of the event? How do you know that it's not working?
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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 =/
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
What you have changed, is the @name variable's value. Not the real event name.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,506
Reaction score
8,144
First Language
German
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
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.
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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 =/
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
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.
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,602
Reaction score
3,831
First Language
Java's Crypt
Primarily Uses
RMMZ
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
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
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.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,506
Reaction score
8,144
First Language
German
Primarily Uses
RMMV
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...
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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

# =============================================================================# 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
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
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

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,602
Reaction score
3,831
First Language
Java's Crypt
Primarily Uses
RMMZ
@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.
 
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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!
 
Last edited by a moderator:

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
185
First Language
Meowish
Primarily Uses
 

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! ;)
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
606
Reaction score
318
First Language
German
Primarily Uses
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
 
Last edited by a moderator:
Joined
Sep 9, 2015
Messages
297
Reaction score
29
First Language
English
Primarily Uses
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?
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

I wish I can work faster on my game. But I don't want to get burned out. :(
I've been working on something on and off for a few years now, and I've been reluctant to share any details on the project before I had anything playable because I did not want to generate hype only for the project to go back on hiatus. That being said I believe what I'm working on is very unique and pushes the boundaries of what RPG Maker projects can be. Bold claims, I know but just wait.
Happy Mother's Day to all the moms :)
Create Anime Art w/ AI, Tall Sprites with Aurora, Customize Variable Display | RPG Maker News #34

[My favorite slow moving track I've made so far]

Forum statistics

Threads
111,207
Messages
1,059,260
Members
144,459
Latest member
juan172
Top