[RMXP] ERROR INVOLVING MAPINFOS.RXDATA [RESOLVED]
Posts
Pages:
1
This is an RPG Maker XP project. I am trying to create the scripts needed for non-scripters to make their own Harvest Moon style crops. I got as far the script for checking if plants are watered overnight, and I am getting an error that is well out of my league. I tried googling it, but I got nothing. I needed to cycle through every event on every map, and the only solution I found involves the rxdata, which I have avoided like the plague up to now. I don't even know a good tutorial for learning that, I just know that some people know it well, and I don't.
I am using the Self Variables from DrakoShade, as well as an original code I put together.
Here's the error:
And just to be thorough, here's the "bedtime" event with the script call:
The game starts fine, but when I try to call the Overnight script, that error comes up. Here's my script:
I feel like there's one too many "ends" in there, but it won't run with any less or more.
Self variable 1 is the main control for the crop event page.
Self switch A is used to check whether the crop has been watered.
Self Switch B checks if the crop is done growing.
If you want to look at the actual game, it can be downloaded from here: https://uploadfiles.io/xqshg
I am using the Self Variables from DrakoShade, as well as an original code I put together.
Here's the error:
And just to be thorough, here's the "bedtime" event with the script call:
The game starts fine, but when I try to call the Overnight script, that error comes up. Here's my script:
class Overnight
def initialize
@maps = []
@farm = 1
map_data = load_data('MapInfos.rxdata')
for i in map_data.keys
@maps.push(load_data(sprintf("Data/Map%03d.rxdata", i)))
end
end
def water_check
for f in 0...@maps[]
@farm = @maps[f]
for e in 0...@farm.events[]
if $game_self_vaiables[[@farm, e, 1]] > 3
if $game_self_switches[[@farm, e, "A"]] == on
$game_self_switches[[@farm, e, "A"]] = off
$game_self_variables[[@farm, e, 1]] += 1
else if $game_self_switches[[@farm, e, "B"]] == off
$game_self_variables[[@farm, e, 1]] = 3
end
end
end
end
end
end
end
I feel like there's one too many "ends" in there, but it won't run with any less or more.
Self variable 1 is the main control for the crop event page.
Self switch A is used to check whether the crop has been watered.
Self Switch B checks if the crop is done growing.
If you want to look at the actual game, it can be downloaded from here: https://uploadfiles.io/xqshg
Would it make any difference whatsoever if the first line that calls the load_data function was...
...instead?
*Edit: Would it also be appropriate in the script-call to write something like...
...this? I suspect you want to use the ".size" property in your for loops (ie: "@maps.size" and "@farm.events.size"), but, I'm not 100% sure.
....should probably be...
map_data = load_data("Data/MapInfos.rxdata")
...instead?
*Edit: Would it also be appropriate in the script-call to write something like...
var = Overnight.new var.water_check
...this? I suspect you want to use the ".size" property in your for loops (ie: "@maps.size" and "@farm.events.size"), but, I'm not 100% sure.
if $game_self_vaiables[[@farm, e, 1]] > 3
if $game_self_variables[[@farm, e, 1]] > 3
Well, typos will definitely kill a script, that's for sure! :)
KK20, a global mod at chaos-project, re-wrote the whole dang thing for me! Some of what you said looks more like his version. It looks like this now:
KK20, a global mod at chaos-project, re-wrote the whole dang thing for me! Some of what you said looks more like his version. It looks like this now:
module Overnight @@maps = {} # Get list of map IDs map_hash = load_data('Data/MapInfos.rxdata') map_hash.keys.each do |id| # Create a hash table where map ID is the key and event IDs are the value @@maps[id] = [] # Load map map = load_data(sprintf("Data/Map%03d.rxdata", id)) # Check every event's name on the map and add it to the list if it is soil map.events.keys.each do |e| @@maps[id].push(e) if map.events[e].name == 'Crop Soil' end end # This method is called when the player goes to sleep def self.water_check @@maps.each do |map_id, events| events.each do |e_id| # If crop event is planted and/or watered if $game_self_variables[[map_id, e_id, 1]] > 3 # If crop was watered if $game_self_switches[[map_id, e_id, "A"]] # Turn switch off and increase event page $game_self_switches[[map_id, e_id, "A"]] = false $game_self_variables[[map_id, e_id, 1]] += 1 # Crop is not finished growing elsif !$game_self_switches[[map_id, e_id, "B"]] # Goes to withered page $game_self_variables[[map_id, e_id, 1]] = 3 end end end end end end
Pages:
1
















