Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    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.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,686
    Blog Entries
    1
    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

  3. #3
    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?

  4. #4
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,686
    Blog Entries
    1
    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.

  5. #5
    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.

  6. #6
    bah, misread that, since the <script> isn't named it can't be replaced? or is this only for template and windowclass elements?

  7. #7
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,686
    Blog Entries
    1
    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>
    the template and chatwindow are named so Im merging at that point.

  8. #8
    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>
    I get an error saying the script can't be loaded. Now there is a file in that location with that file name, so I've no idea why I'm getting the error.
    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
    It doesn't do anything. I don't get a message in the console.
    Again no idea why it's doing this.

  9. #9
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,686
    Blog Entries
    1
    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?

  10. #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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in