Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Event name use in a script
lowcku
post Apr 17 2011, 07:48 PM
Post #1


Level 3
Group Icon

Group: Member
Posts: 31
Type: None
RM Skill: Undisclosed




i'm trying to programer a game scrip and i want to use the event's Name not the id, as a tiger. i know the name is a string.
here's the code i'm using...

#begin
#Print "___________"
#end
i don't know the rest. i know to print the id is @event_id, how would i print the name? @event_name does not work.

note: i'm still in the testing phase so i'm just looking around using print statements.
Go to the top of the page
 
+Quote Post
   
stripe103
post Apr 18 2011, 01:41 AM
Post #2


PHP ERROR: Couldn't get value from UInteger. Value too large
Group Icon

Group: Revolutionary
Posts: 737
Type: Mapper
RM Skill: Intermediate




If I'm correct, the variable @event_id is an integer. It only holds the id of the event, not the event object itself. To access the event object, you have to write
CODE
$game_map.events[@event_id]

I don't currently remember how to access the name, but I'll search.

EDIT: I've searched where I could think of, and it seems the event name is only used in the editor and not in the game. Can anyone else think of anything?

This post has been edited by stripe103: Apr 18 2011, 02:06 AM


__________________________

By Axerax

The rest of my sig



Go to the top of the page
 
+Quote Post
   
brewmeister
post Apr 18 2011, 10:36 AM
Post #3


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




QUOTE (stripe103 @ Apr 18 2011, 05:41 AM) *
If I'm correct, the variable @event_id is an integer. It only holds the id of the event, not the event object itself. To access the event object, you have to write
CODE
$game_map.events[@event_id]

I don't currently remember how to access the name, but I'll search.

EDIT: I've searched where I could think of, and it seems the event name is only used in the editor and not in the game. Can anyone else think of anything?


You didn't search the most obvious place.... the help docs.
In RGSS Reference Manual --> Game Library --> RPGXP Data Structure --> RPG::Event
has a property called 'name'

It looks like you are trying to use this from the Interpreter. (in an event "Script" call)

The @event_id is a property of the Game_Event, which also has a property called @event that is an RPG::Event

If you add this statement at the top of the Game_Event script, near the other attr_reader statements....

attr_reader :event

then you can access the event property of the Game_Event, so your command would be:


CODE
$game_map.events[@event_id].event.name



__________________________
Go to the top of the page
 
+Quote Post
   
lowcku
post Apr 18 2011, 07:33 PM
Post #4


Level 3
Group Icon

Group: Member
Posts: 31
Type: None
RM Skill: Undisclosed




Thanks very much, this really helps. i'll see if it works. Again thanks to the both of you. biggrin.gif

This post has been edited by lowcku: Apr 18 2011, 08:47 PM
Go to the top of the page
 
+Quote Post
   
lowcku
post Apr 18 2011, 08:59 PM
Post #5


Level 3
Group Icon

Group: Member
Posts: 31
Type: None
RM Skill: Undisclosed




sorry, i need your help again. it is not working for me here is the script i'm testing
CODE
class Test_Call
def initialize
print $game_map.events[@event_id].event.name
end
end


i am using the Even scrip call to call this from the script editor using.

CODE
Test_Call.new


however i'm getting a error message saying "undefined method 'event'". what am i doing wrong.
note: i'm just trying to print the event name on screen in a text box.


EDIT: i think i got it working however it return "nil" in the text box.

This post has been edited by lowcku: Apr 18 2011, 09:17 PM
Go to the top of the page
 
+Quote Post
   
brewmeister
post Apr 19 2011, 06:15 AM
Post #6


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




as long as you add:

CODE
attr_reader :event


to the top of the Game_Event script, you can just use:

CODE
print $game_map.events[@event_id].event.name


in an event script command. You don't need to create a class.

In the class you wrote, you use @event_id. But your class has no idea what that is. If it's doesn't error, then it must be initializing @event_id to 0, and there is no event 0, so it returns nil.

You could pass the event_id into the class

CODE
class Test_Call
    def initialize(event_id)
        print $game_map.events[event_id].event.name
    end
end


then call the class with

CODE
Test_Call.new(@event_id)


This works because the event you call it from is aware of @event_id. (It gets initialized in the interpreter)

This post has been edited by brewmeister: Apr 21 2011, 05:51 AM


__________________________
Go to the top of the page
 
+Quote Post
   
lowcku
post Apr 19 2011, 08:17 PM
Post #7


Level 3
Group Icon

Group: Member
Posts: 31
Type: None
RM Skill: Undisclosed




Thank you for all your help. It is working now however, when you recalled the "event_id" it should be beside the def "initialize". As follows then it will work.
CODE
class Test_Call
def initialize(event_id)
print $game_map.events[event_id].event.name
end
end

again thanks.
Go to the top of the page
 
+Quote Post
   
brewmeister
post Apr 20 2011, 10:41 AM
Post #8


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




oops! wink.gif


__________________________
Go to the top of the page
 
+Quote Post
   
lowcku
post Apr 20 2011, 05:28 PM
Post #9


Level 3
Group Icon

Group: Member
Posts: 31
Type: None
RM Skill: Undisclosed




yay you rock, I've been trying to make this script for a few days now. lol

it works great, thanks again.

This post has been edited by lowcku: Apr 20 2011, 05:29 PM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 05:11 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker