swiftdeathsk
Member
This is my first RGSS script I've attempted, and I've read tutorials, and have other programming language experiences, so, for the most part, i understand the rules of programming, the main thing i'm having trouble with is learning the syntaxes and keywords, etc. I've also posted this help topic on a few other forums, none of which have been answered with help...
anyways, what I'm trying to do with this script is allow the creator to link maps together via rgss instead of a ton of teleport events. how it works is you will place the following on the end of each map name:
but instead of #, replace it with the number of the map you wish to link it to. (so N:4 would link the map at the top (north / N) to the bottom of map 4). The script will then cut up the end of the map's name after the '{' and check to see what number is after each of the :'s and then make it so that when the player is at the edge of the map, then presses the arrow key in that direction, they will "walk off the map" and appear on the next map.
the part that is messing me up is the part where it "cuts up" the map name to read the map directions (the letters N/E/S/W) and the numbers that the map is linked to. i dont understand it's syntax. I looked it up in the RMXP help file, but it's just confusing, and i tried a few of the different syntaxes that might have worked, but they all give me errors.
here is the current script I have done so far (I'm almost positive that this will have some errors apart from the error I have described, so if you can point them out and explain them, that would be helpful ).
I cant even tell if this script is even correct, because i copied this part:
from another person's script (which was a multiple spoils-drop from enemies script), but it didnt do the same thing as my script (it cut up the name, but it didnt have anything to do with map names), so I'm not sure if it's going to work for my script... if not, could someone please explain to me how i can do this for my script?
now for the (current) error i get when i run this script:
this is line 25:
by the way, this is the main error i get whenever i change the syntax of this line (and the other lines). I dont know what causes the Fixnum errors, so if possible, it would be appreciated to let me know so i can prevent this error in the future.
here is a demo of my game, if needed: http://www.megaupload.com/?d=DPRO91XL
Also, if you have the time, because I am still learning RGSS, and wish to learn more so I can improve my knowledge of it, perhaps you could explain what/how you fixed it, (dont be scared off by this comment like others have before, this is optional , so if you dont want to, i can just try to break down your script myself.)
anyways, what I'm trying to do with this script is allow the creator to link maps together via rgss instead of a ton of teleport events. how it works is you will place the following on the end of each map name:
Code:
{N:#,E:#,S:#,W:#
the part that is messing me up is the part where it "cuts up" the map name to read the map directions (the letters N/E/S/W) and the numbers that the map is linked to. i dont understand it's syntax. I looked it up in the RMXP help file, but it's just confusing, and i tried a few of the different syntaxes that might have worked, but they all give me errors.
here is the current script I have done so far (I'm almost positive that this will have some errors apart from the error I have described, so if you can point them out and explain them, that would be helpful ).
Code:
#---------------------------#
# Auto Map Connection Script#
# by SwiftDeathSK #
#---------------------------#
# What it Does: #
# This allows you to link #
# maps to each other when #
# you walk off the edge of #
# a map without using #
# a ton of events. #
#---------------------------#
# How To Use: #
# ***FILL THIS IN LATER!*** #
#---------------------------#
#---------------------------#
class Map_Connect < Game_Player
def initialize
@map_dir = []
@map_change = []
loop do
@map_name = $game_map.map_id
get_id = @map_name
string = @map_name.slice!(get_id + 1, @map_name.size - 1)
@map_name.slice!("{")
new_str = string.split(',')
for k in 0...new_str.size
str = new_str[k].split(':')
@map_dir.push(str[0])
@map_change.push(str[1])
end
if $game_player.x >= 0 and $game_player.y = 0 and @map_dir = 1
if input.dir4 = 8
$game_map.map_id = @map_change
end
end
if $game_player.x >= 0 and $game_player.y = $game_map.height and @map_dir = 3
if input.dir4 = 2
$game_map.map_id = @map_change
end
end
if $game_player.x = 0 and $game_player.y >= 0 and @map_dir = 4
if input.dir4 = 4
$game_map.map_id = @map_change
end
end
if $game_player.x = $game_map.width and $game_player.y >= 0 and @map_dir = 2
if input.dir4 = 6
$game_map.map_id = @map_change
end
end
end
end
end
I cant even tell if this script is even correct, because i copied this part:
Code:
@map_dir = []
@map_change = []
loop do
@map_name = $game_map.map_id
get_id = @map_name
string = @map_name.slice!(get_id + 1, @map_name.size - 1)
@map_name.slice!("{")
new_str = string.split(',')
for k in 0...new_str.size
str = new_str[k].split(':')
@map_dir.push(str[0])
@map_change.push(str[1])
end
now for the (current) error i get when i run this script:
Script 'Map_Connect' line 25: NoMethodError occurred.
undefined method 'slice!' for 1:Fixnum
this is line 25:
Code:
string = @map_name.slice!(get_id + 1, @map_name.size - 1)
by the way, this is the main error i get whenever i change the syntax of this line (and the other lines). I dont know what causes the Fixnum errors, so if possible, it would be appreciated to let me know so i can prevent this error in the future.
here is a demo of my game, if needed: http://www.megaupload.com/?d=DPRO91XL
Also, if you have the time, because I am still learning RGSS, and wish to learn more so I can improve my knowledge of it, perhaps you could explain what/how you fixed it, (dont be scared off by this comment like others have before, this is optional , so if you dont want to, i can just try to break down your script myself.)