Ugh! I didn't even consider batch switch/variable changes.
LOL! You tease me 🙂
I've already created this, in the form of an exporter script. I will add an in-game version to my to-do list 🙂
Ugh! I didn't even consider batch switch/variable changes.
LOL! You tease me 🙂
Ah, I was debating whether to break the structure right down (store the source map/database item separate to its name) or not. I decided not, for the sake of making it easier to print. But now that I think about the next step, I really should have saved every piece in its own property. Going to be a bit difficult extracting the map id from a string that says Map 3: Temple. I will have to redo that - thankfully I think it's only a one-line change.
What's the difference between me saying this:
def self.add(type, id, reference) $data_xrefs[type] = [] if $data_xrefs[type].nil? $data_xrefs[type][id] = [] if $data_xrefs[type][id].nil? $data_xrefs[type][id].push(type, id, reference) end def self.save_xref(type, id, reference = command(@cmd)) xref = XReference.new(@source, sprintf('%d: %s', @refid, @ref), @page, @line, reference) add(type, id, xref) end
This is just the same way the $data_* classes work. If I want to look at actors, I have to do $data_actors[id] and be aware of nil elements, as well as its structure.The only references to $data_xrefs is within the module itself, and within the windows and scenes I write for them. So yes, I could provide a getter method rather than use a global variable for the hash (a setter method, I think, is pointless, because the only additions are done within the module, not from outside), and return either an array or nil, but the scene/window would still have to cater for nil or empty results. I'm not anticipating that anyone will be writing add-on modules or classes for this, the way we all do with the database classes.
Refactoring is about altering the structure/architecture of code without change the functionality. Why refactor? Multiple reasons can exist. The original abstraction level for an object changed, responsibility changed. Maybe you want to add a new feature where a different structure is necessary or will help. Typically, the goal of improving the code and design is implied.
You are right that consistency is good to preserve. In cases where it leads to a sub-optimal solution you would have to weigh the benefits of the preferred method versus the detriments caused breaking the consistency. Rarely is there a specific right or wrong. In the name of teaching I suggest we look differently on this. Do not follow the normal $data_ pattern. Revisiting this later once you have had some time to play around with different concepts sounds like a good idea.
Make it so that the scenes/windows do not have to cater for nil. Empty results is a different matter, one they still should cater to.
Blah, blah, blah! I want MA. You're so mean 🙁
An RTP example would be the RPG::UsableItem:😀amage class, where the Damage object is referenced by an RPG::Skill or RPG::Item, but it's the damage that handles all the damage calculations, and not the skill or item that's doing it.
skill.eval_use_condition
skill.use_conditions.each {|cond| cond.eval_use_condition }
Original thread: https://forums.rpgmakerweb.com/threads/cross-reference-tool.20077/