Monsto Brukes Posted July 2, 2019 Posted July 2, 2019 The script "Place" is part of a pretty old mod. I don't know if it's a house of cards or not, but I wanted to add some functionality. "Extending" the original I figd was the way to do it. Doesn't work for me. I originally had the extending script in another mod, but it doesn't work even when the old and new pex and psc are right next to each other. And CKWiki doesn't give any clue to obscure rules to the Extends keyword. What did I miss here?
EgoBallistic Posted July 2, 2019 Posted July 2, 2019 3 hours ago, Monsto Brukes said: The script "Place" is part of a pretty old mod. I don't know if it's a house of cards or not, but I wanted to add some functionality. "Extending" the original I figd was the way to do it. Doesn't work for me. I originally had the extending script in another mod, but it doesn't work even when the old and new pex and psc are right next to each other. And CKWiki doesn't give any clue to obscure rules to the Extends keyword. What did I miss here? "Extends" doesn't mean it changes the existing script, it means it creates a new script that inherits the functionality of the old one. The purpose of this feature is to make variants of the same type of object, that have the same external interface but behave differently internally. When you create a quest script, that script "extends Quest". That means it inherits the features of the basic Quest objects. You can start, stop, setstage, etc. But your script doesn't actually change the base Quest script, it just inherits the Quest script's functions and attributes. This inheritance is really useful in mods. Let's say you're making a bondage mod. You create a script called "GenericRestraints" that provides some generic functions - forceEquip, unEquip, lockRestraint, unlockRestraint. Then you make some scripts for "Handcuffs" and "WristRopes", each of which extends GenericRestraints. Each of those implements those same functions, but with different details. Handcuffs requires keys to open, ropes can be unequipped if you have a knife in your inventory, etc. Those scripts are then attached to WristRope and Handcuffs objects. Then you can call the same functions from the GenericRestraints script on either Handcuffs or Wristropes object and they will behave according to their own scripts. So getting back to your Place script, just creating a script that "extends Place" won't do anything in and of itself. If you want to modify the original Place, you will need to modify its script.
Monsto Brukes Posted July 2, 2019 Author Posted July 2, 2019 Quote "Extends" doesn't mean it changes the existing script, it means it creates a new script that inherits the functionality of the old one. . . . So getting back to your Place script, just creating a script that "extends Place" won't do anything in and of itself. If you want to modify the original Place, you will need to modify its script. CKWiki says the exact opposite. Quote Overview Script extending is the act of taking a script that almost does what you want, and then modifying some of its events or functions to do something different without editing the original script. Then goes on to give examples of the conditions when the new/extension script will override, and add to, the functions and events the existing script. The problem I'm having is that an event, onActivate, doesn't exist in the original script and doesn't work in the extension script. When I add it to the original script, it works. I didn't want to do that for organizational purposes. I want to keep the original mod free of my addons, so that if there's a problem later on, then I can more quickly deal with it . . . as opposed to if my changes are buried in among the original code spread across several scripts.
EgoBallistic Posted July 2, 2019 Posted July 2, 2019 Do you maybe see how this 9 hours ago, EgoBallistic said: So getting back to your Place script, just creating a script that "extends Place" won't do anything in and of itself. If you want to modify the original Place, you will need to modify its script. has something to do with this 26 minutes ago, Monsto Brukes said: The problem I'm having is that an event, onActivate, doesn't exist in the original script and doesn't work in the extension script. When I add it to the original script, it works. ? When you create a new script that extends another script, you are creating a whole new script that is based on the original but does not change it in any way. What you put in that new script has no effect on the items the original script is bound to. That's why your changes only work when you add them to the original script.
Monsto Brukes Posted July 3, 2019 Author Posted July 3, 2019 Alright, looks like a Language Barrier problem. I'm thinking "of COURSE it doesn't change the script, I wouldn't expect it to overwrite anything in the script file. But according to CKWiki, the functions in the original will be superseded." But what you're saying is that the way the game processes the original script is unchanged. That the changes appearing in the extended script do not propagate upwards to the parent/original script. In other words. . . Place and NEWPlace both need to be on the entity for the events in the extended script to be considered. Is that correct?
EgoBallistic Posted July 3, 2019 Posted July 3, 2019 42 minutes ago, Monsto Brukes said: But what you're saying is that the way the game processes the original script is unchanged. That the changes appearing in the extended script do not propagate upwards to the parent/original script. Exactly. All of the features of the parent/original propagate downward to (the proper term is "are inherited by") the extended script. But not the other way around. 42 minutes ago, Monsto Brukes said: Place and NEWPlace both need to be on the entity for the events in the extended script to be considered. No, only NEWPlace needs to be on the entity. NEWPlace inherits everything that Place contains, plus any additions and alterations you made. You definitely don't want both on the same object.
Monsto Brukes Posted July 3, 2019 Author Posted July 3, 2019 8 hours ago, EgoBallistic said: No, only NEWPlace needs to be on the entity. Great. Thanks.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.