[XP] Inheritance - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Code Support (https://www.save-point.org/forum-20.html) +--- Thread: [XP] Inheritance (/thread-3251.html) Pages:
1
2
|
RE: [XP] Inheritance - xuroth - 03-08-2011 Ok, it tried a new p command right after my block tests if Shift is pressed and still nothing. that means that my entire class that aliases scene_item is not working... RE: [XP] Inheritance - DerVVulfman - 03-08-2011 Place your p command before and after your alias statement. Different text of course. If it executes before but not after your alias, then it has something to do with the method you're using. If it executes both print statements, then your method is running through all the statements. And if neither execute... um... WHAT? RE: [XP] Inheritance - Charlie Fleed - 03-08-2011 Sorry if I cut in without reading the whole thread. I'm answering to the initial question here. When an inherited class defines a method that exists in the base class, it can use the reserved word super to call the base class version of the method. Aliasing isn't necessary if you can use this technique in your code. RE: [XP] Inheritance - xuroth - 03-08-2011 i have tried super and i tried using p at different points. simply put, none of my methods are being used, though the class is being called just fine. I placed a p command outside the methods and the game displayed it. so this just will NOT work unless it is actually pasted into Scene_item, evidently. I dont understand. I thought alias could take an existing method and add to it without editing the script directly... I figured super would call the original code in the super classes method of the same name, and then run the new code.... Maybe i just dont get it RE: [XP] Inheritance - xuroth - 03-09-2011 ok, so I played around with changing the color of the title HP in Window_BattleStatus so that when in battle, 'HP' is shown green. this was just a simple way to try to alias methods, though Im not sure if this is done correctly. This DOES change the Name of 'HP', but I am curious if this would be no-no for compatibility? Essentially, I re-wrote def refresh so that it calls my method draw_colored_hp instead of draw_actor_hp. Basically, in terms of compatibility and/or scripting ettiquette, is this acceptable? Man, I suck at this! RE: [XP] Inheritance - DerVVulfman - 03-10-2011 By compatibility standards, it is a no-no. However, thanks for noting it and asking. We do prefer to use alias whenever possible. BUT... if RPGMaker's database editor does not allow you to change words like STR, DEX, HP, Gold, and the like, what choice DO you have? When you make a script, it would be good to let anyone using it know what methods you rewrote. That way they would know what's up if they experience a problem. I prefer to add a configuration section in my scripts to allow the end user (ie you) to be able to change my custom texts... if needed. Using a config section is easy enough. Working on making a good one... practice practice practice. EDIT: *DerVVulfman now looks at the script* EDIT 2: Remember how we talked about inheritance and that one script inherits the methods from another? Window_Battlestatus inherits the draw_HP command from Window_Base... the class that defined it. However, if you have your own 'draw_actor_hp' in the Window_Battlestatus class, it only affects that class. Your menus and all other HP drawing systems will still use the default one. You coulda just use the whole thingie. ^_^ RE: [XP] Inheritance - xuroth - 03-11-2011 I figured it out. My problem was how I was aliasing the methods. I wasnt calling the old method correctly, but now that I learned, I have adapted my script. In fact, it has allowed me to finish my first script which I will post here shortly. RE: [XP] Inheritance - DerVVulfman - 03-11-2011 Ah, be forewarned about aliases. They are tricky devils. Picture an method like this: Code: def method_one(x) It adds 3 to what is entered. And then returns it. Aliasing this should be like this... Code: alias new_method_one method_one This new alias retrieves the value gained from the original method, and then adds 40 to it before returning it. This way, you can alter values that are generated and returned by methods. RE: [XP] Inheritance - Victor Sant - 03-12-2011 Another thing that you might be careful: don't use aliases with methods that exists only on the parent classes. #Wrong Code: class Parent_Class Instead use the super Code: class Parent_Class RE: [XP] Inheritance - DerVVulfman - 03-13-2011 Ah, so is that the culprit of the dreaded F12 glitch? When I encounter and narrow the offending method, I've been wrapping them in an if...end block that Seph showed me years ago. |