-
May 9th, 2020, 22:58 #1
- Join Date
- Nov 2019
- Posts
- 282
How to replace a built in script or modify it
How would I go about replacing a script without completely replacing the xml/lua files.
I want to make the damage section of the item window show up for shields, and I don't want to replace the entire xml file to do so.
I use other extensions that add fields to items so I don't want to break them.
I'm new to this so still figuring out how to do things.
Thanks.
-
May 10th, 2020, 04:47 #2
you start talking about xml/lua and then reference only xml but your topic is about a script (lua)
use merge="join" or merge="replace" in xml
-
May 10th, 2020, 07:31 #3
- Join Date
- Nov 2019
- Posts
- 282
so if I use merge join in the xml doing
<script file="my name.lua"/> can I name functions by the same name replacing them, or how do I go about ensuring my script gets called after the original one is?
So that I can make something normaly not visible is visible?
-
May 10th, 2020, 11:09 #4
You can merge against any xml element that is named. If its not named (it probably should be) then you cant merge against it.
Rulesets load before extensions.
Extensions load somewhat randomly unless you set a load order.
-
May 10th, 2020, 13:43 #5
- Join Date
- Nov 2019
- Posts
- 282
So I could instead of putting merge="join" in the windowclass I could put <script merge="replace" file="myfile.lua" /> to replace just that part of the windowclass?
Thanks.
I'll try that out.
-
May 10th, 2020, 14:26 #6
- Join Date
- Nov 2019
- Posts
- 282
bah, misread that, since the <script> isn't named it can't be replaced? or is this only for template and windowclass elements?
-
May 10th, 2020, 14:37 #7
Example:
Code:<template name="chatwindow_step" merge="join"> <chatwindow name="chat" merge="join"> <modeframe mode="damned" name="chatframe_spell" offset="20,11,20,9" mergerule="replace" /> <modeframe mode="chat" name="chatframe_chat" offset="15,5,5,5" mergerule="replace" /> <modeframe mode="story" name="chatframe_story" offset="15,10,15,10" mergerule="replace" /> <modeframe mode="whisper" name="chatframe_whisper" offset="15,5,5,5" mergerule="replace" /> <linkcolor>0000FF</linkcolor> <linkicon normal="button_link" pressed="button_link_down" /> <droptypes> <type>dice</type> <type>number</type> <type>string</type> </droptypes> <script file="desktop/scripts/chat_window.lua" /> </chatwindow> </template>
-
May 10th, 2020, 20:30 #8
- Join Date
- Nov 2019
- Posts
- 282
Thanks for your help.
So I did the following:
Code:<windowclass name="item_main" merge="join"> <script file="campaign/scripts/item_main_ACIM.lua" /> <sheetdata> <line_column name="divider10" insertbefore="ac_label" /> </sheetdata> </windowclass>
If I change iremove the "_ACIM" the error goes away. Again no idea why.
As for the script I did the following:
I copied the script from item_main.lua and changed it.
Code:function onInit() update(); end function VisDataCleared() update(); end function InvisDataAdded() update(); end function update() Debug.console("Been here"); end
Again no idea why it's doing this.
-
May 10th, 2020, 23:55 #9
The error goes aay when you remove the _ACIM because it is then loading the CoreRPG version of the script.
There must be something wrong with the file naming, path or file content maybe?
-
May 14th, 2020, 21:59 #10
Trying to do this same sort of thing. I can get my new script called, but is there any way for my new script to reference the old one and tell it to do it's update(), or some other way to have that old update() method run? I just have like 3 lines of code that I need to run in the update() method, and I don't want to replace the entire item_main.lua file with a copy and pasted one that has my 3 lines of code added, since then I'd have to make constant extension updates if the ruleset ever updates that file.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks