Using XSL

3 replies [Last post]
Joined: 09/27/2014

Yesterday, I made a mod that changes the color of a Pokey to various random colors. I got into a big mess when it comes to editing XSL. If the Pokey appears in a certain color like blue, I want the attached body to be the same color (blue), and if it comes in red, the attached body will be red, and so on. My result was everything to turn out random. Sometimes the Pokey appears with the attached body; it turns normal when attached, sometimes it's normal, and stays normal when attached, but other times it's the other way around! Even the color changes when the Pokey is attached, and I don't know what to do!

Here are the XSL codes:

balls.xml.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
  <!-- Copy everything not matched by another rule -->
  <xsl:template match="* | comment()">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
 
 
<xsl:template match="/ball/part[@layer = 0]">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="image">IMAGE_BALL_POKEY_BODY1,IMAGE_BALL_POKEY_BODY2,IMAGE_BALL_POKEY_BODY3,IMAGE_BALL_POKEY_BODY4,IMAGE_BALL_POKEY_BODY5,IMAGE_BALL_POKEY_BODY6,IMAGE_BALL_POKEY_BODY7,IMAGE_BALL_POKEY_BODY8,IMAGE_BALL_POKEY_BODY9,IMAGE_BALL_POKEY_BODY10,IMAGE_BALL_POKEY_BODY11,IMAGE_BALL_POKEY_BODY12,IMAGE_BALL_POKEY_BODY13,IMAGE_BALL_POKEY_BODY14,IMAGE_BALL_POKEY_BODY15,IMAGE_BALL_POKEY_BODY16,IMAGE_BALL_POKEY_BODY17,IMAGE_BALL_POKEY_BODY18,IMAGE_BALL_POKEY_BODY19,IMAGE_BALL_POKEY_BODY20,IMAGE_BALL_POKEY_BODY21,IMAGE_BALL_POKEY_BODY22,IMAGE_BALL_POKEY_BODY23,IMAGE_BALL_POKEY_BODY24,IMAGE_BALL_POKEY_BODYSTUCK1,IMAGE_BALL_POKEY_BODYSTUCK2,IMAGE_BALL_POKEY_BODYSTUCK3,IMAGE_BALL_POKEY_BODYSTUCK4,IMAGE_BALL_POKEY_BODYSTUCK5,IMAGE_BALL_POKEY_BODYSTUCK6,IMAGE_BALL_POKEY_BODYSTUCK7,IMAGE_BALL_POKEY_BODYSTUCK8,IMAGE_BALL_POKEY_BODYSTUCK9,IMAGE_BALL_POKEY_BODYSTUCK10,IMAGE_BALL_POKEY_BODYSTUCK11,IMAGE_BALL_POKEY_BODYSTUCK12,IMAGE_BALL_POKEY_BODYSTUCK13,IMAGE_BALL_POKEY_BODYSTUCK14,IMAGE_BALL_POKEY_BODYSTUCK15,IMAGE_BALL_POKEY_BODYSTUCK16,IMAGE_BALL_POKEY_BODYSTUCK17,IMAGE_BALL_POKEY_BODYSTUCK18,IMAGE_BALL_POKEY_BODYSTUCK19,IMAGE_BALL_POKEY_BODYSTUCK20,IMAGE_BALL_POKEY_BODYSTUCK21,IMAGE_BALL_POKEY_BODYSTUCK22,IMAGE_BALL_POKEY_BODYSTUCK23,IMAGE_BALL_POKEY_BODYSTUCK24</xsl:attribute>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>  
 
 
 
 
</xsl:transform>

resources.xml.xsl

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
  <!-- Copy everything not matched by another rule -->
  <xsl:template match="* | comment()">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
 
 
  <xsl:template match="/ResourceManifest/Resources">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
 
 <SetDefaults path="res/balls/Pokey/" idprefix="IMAGE_BALL_POKEY_" />
      <Image id="BODY1"	          path="body1"/>
        <Image id="BODYSTUCK1"	          path="bodyStuck1"/>
      <Image id="BODY2"	          path="body2"/>
        <Image id="BODYSTUCK2"	          path="bodyStuck2"/>
      <Image id="BODY3"	          path="body3"/>
        <Image id="BODYSTUCK3"	          path="bodyStuck3"/>
      <Image id="BODY4"	          path="body4"/>
        <Image id="BODYSTUCK4"	          path="bodyStuck4"/>
      <Image id="BODY5"	          path="body5"/>
        <Image id="BODYSTUCK5"	          path="bodyStuck5"/>
      <Image id="BODY6"	          path="body6"/>
        <Image id="BODYSTUCK6"	          path="bodyStuck6"/>
      <Image id="BODY7"	          path="body7"/>
        <Image id="BODYSTUCK7"	          path="bodyStuck7"/>
      <Image id="BODY8"	          path="body8"/>
        <Image id="BODYSTUCK8"	          path="bodyStuck8"/>
      <Image id="BODY9"	          path="body9"/>
        <Image id="BODYSTUCK9"	          path="bodyStuck9"/>
      <Image id="BODY10"	          path="body10"/>
        <Image id="BODYSTUCK10"	          path="bodyStuck10"/>
      <Image id="BODY11"	          path="body11"/>
        <Image id="BODYSTUCK11"	          path="bodyStuck11"/>
      <Image id="BODY12"	          path="body12"/>
        <Image id="BODYSTUCK12"	          path="bodyStuck12"/>
      <Image id="BODY13"	          path="body13"/>
        <Image id="BODYSTUCK13"	          path="bodyStuck13"/>
      <Image id="BODY14"	          path="body14"/>
        <Image id="BODYSTUCK14"	          path="bodyStuck14"/>
      <Image id="BODY15"	          path="body15"/>
        <Image id="BODYSTUCK15"	          path="bodyStuck15"/>
      <Image id="BODY16"	          path="body16"/>
        <Image id="BODYSTUCK16"	          path="bodyStuck16"/>
      <Image id="BODY17"	          path="body17"/>
        <Image id="BODYSTUCK17"	          path="bodyStuck17"/>
      <Image id="BODY18"	          path="body18"/>
        <Image id="BODYSTUCK18"	          path="bodyStuck18"/>
      <Image id="BODY19"	          path="body19"/>
        <Image id="BODYSTUCK19"	          path="bodyStuck19"/>
      <Image id="BODY20"	          path="body20"/>
        <Image id="BODYSTUCK20"	          path="bodyStuck20"/>
      <Image id="BODY21"	          path="body21"/>
        <Image id="BODYSTUCK21"	          path="bodyStuck21"/>
      <Image id="BODY22"	          path="body22"/>
        <Image id="BODYSTUCK22"	          path="bodyStuck22"/>
      <Image id="BODY23"	          path="body23"/>
        <Image id="BODYSTUCK23"	          path="bodyStuck23"/>
      <Image id="BODY24"	          path="body24"/>
        <Image id="BODYSTUCK24"	          path="bodyStuck24"/>
    </xsl:copy>
  </xsl:template>
</xsl:transform>

Is there a way to change these codes to the way I want the images to appear on the Pokeys? If there isn't, then all the time I took to make the images has been completely wasted. Sad

(P.S. I know this mod changes the appearance of one single ball, and the ball originally appeared in only 2 levels, but apparently a lot of people like this ball. Tongue)

Be happy and live life at your own pace

Joined: 08/06/2010

Unfortunately there is not. All parts are selected randomly for each ball.

However, you could make multiple goomods for different colors, and allow players to turn the Pokey whatever color they want. Or you could split the image into three parts: the ball itself, the unattached spikes, and the attached spikes. Make the ball part appear in all states and colorize only that image.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.

Joined: 09/27/2014

I don't want to make them all separate goomods, because you can only use one at a time and it takes forever to get through all 24 of them, and I don't know how to "split" images without taking out the transparent background.

If my only choice would be to make those separate goomods, is it OK to merge them all in one?

Be happy and live life at your own pace

Joined: 08/06/2010

Ivan187 wrote:
If my only choice would be to make those separate goomods, is it OK to merge them all in one?

I don't quite understand what you mean--how would you merge a "turn the ball red" extension with a "turn the ball blue" one? Either one would override the other, so it's not really a merge, or it would be randomized, which is what you're trying to avoid.

Another Planet finally has an official release! Download chapters 1 through 3 here! Thank you for waiting so long while I kept starting over.