Need a bit of help

AriArk

Villager
Member
Joined
Jul 12, 2013
Messages
25
Reaction score
0
First Language
English
Primarily Uses
I am currently making a teleport script which I have got a problem with. I need to allow the user to put as many "add_command()" without actually writing "add_command()", just filling in the following variables:    

@numberteleports = 1 # Put how many teleports you have in here# Teleport 1 @tp_1_id = 1 # A no that is different for all TP's @tp_1_name = "Example" # A name to identify the TP @tp_1_text = "Example" # The text that will be shown in game @tp_1_map_id = 1 # The number associated with the map you're teleporting to @tp_1_map_x = 5 # The X possition where you want to TP to @tp_1_map_y = 5 # The Y possition where you want to TP to @tp_1_map_d = 4

I would prefer it if I didn't have number of teleports but I can have that. I want people to just be able to copy and paste the "Teleport 1", change all the 1's to 2, change the number of teleports and then I could script the rest. After that I have:

def make_command_list add_command()and I want all the teleports that the user makes to have a seperate "add_command".

I hope I have been as clear as possible. And thanks in advance!
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
your_counter.each.with_index(1) do | lalala, i| #lalala is irrelevant, but i is the indexAt default, with_index will start at 0.

Code:
your_counter.each.with_index do | asd, i|  #starts at 0  add_command("Tele#{i}", yadayada, yadayada, yadayada)end
 

AriArk

Villager
Member
Joined
Jul 12, 2013
Messages
25
Reaction score
0
First Language
English
Primarily Uses
your_counter.each.with_index(1) do | lalala, i| #lalala is irrelevant, but i is the indexAt default, with_index will start at 0.

your_counter.each.with_index do | asd, i| #starts at 0 add_command("Tele#{i}", yadayada, yadayada, yadayada)end
I understand the second part and what to do with that but where do I put the first line of code?

I have this at the moment:

Code:
   class Teleportwindow < Window_Command     def make_command_list       counter.each.with_index do | asd, i|       add_command(tp_text{i}, :tp_name{i})     end   end
 
Last edited by a moderator:

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Well, you would like the user to be able to see the choices, right? One way to do it is by using custom window derived from window_command.

class Window_Teleport < Window_Commanddef make_command_list add_teleport_commandsenddef add_teleport_commands (1..get_number_teleport_here).each do |i| add_command("Teleport Area #{i}", teleport_to_destination(i)) endenddef teleport_to_destination(destination) #do your stuff hereendSince you're using int as your # of teleport, you can use range to do the loop.  

(start_from_number..end_at_number).each do |number| endor

Code:
(start_from_number...end_right_before_number).each do |number| end
 
Last edited by a moderator:

AriArk

Villager
Member
Joined
Jul 12, 2013
Messages
25
Reaction score
0
First Language
English
Primarily Uses
What about for create_command_window? The one with the @command_window.set_handler - how does that work with this?
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Slot_Number = 10class Window_Slot < Window_Command def make_command_list (1..Slot_Number).each do |i| add_command("slot#{i}", :anything_goes_lol) end endendOn the Scene, you could do

@window_slot = Window_Slot.new@window_slot.set_handler:)anything_goes_lol, method:)do_teleport))If you are also wondering how to determine the teleport #, then I suggest you check the Scene_File and its inheritance (Scene_Save and Scene_Load). Particularly check how the index-ing works.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,583
Latest member
write2dgray
Top