Working on a simple mod to start, need some help with code.

Discuss and distribute tools and methods for modding. Moderator - Grognak
Post Reply
ForrestGump
Posts: 5
Joined: Sat Nov 17, 2012 12:11 pm

Working on a simple mod to start, need some help with code.

Post by ForrestGump »

The idea of this mod is to delay the rebel fleet for 15 turns and give the player bonus scrap when they first start the game and when they first jump into a new sector.

It doesn't appear to be working (game crashes when you try and start it from the hangar) I'm hoping someone can tell me what I did wrong, maybe provide a simpler version of the code or something. Its my first time playing around with modding this great game. Here's what I got so far:

Code: Select all

<!-- Gumpmod mod -->

<event name="START_GAME">
	<text>The data you carry is vital to the remaining Federation fleet. You'll need supplies for the journey, so make sure to explore each sector before moving on to the next. But get to the exit before the pursuing Rebel fleet can catch up! The rebel fleet has been delayed due to some inner rebellions.</text>
    <modifyPursuit amount="-15" />
    <choice>
		<text>Continue...</text>
        <text>You find the remains of a mighty battle directly in front of your ship. You harvest as much scrap as you can.</text>
	    <autoReward level="HIGH">scrap_only</autoReward>
    </choice>
    <choice>
        <text>Continue...</text>
        <text>Just as you're about to commit your first FTL jump, another partially destroyed ship drifts into your path. You harvest as much scrap as you can.</text>
        <autoReward level="HIGH">scrap_only</autoReward>
    </choice>
    <choice>
        <text>Continue...</text>
    </choice>
</event>

<event name="START_BEACON">
	<text>Welcome to a new sector! Get to the exit beacon and jump to the next sector before the pursuing Rebels catch you!</text>
    <modifyPursuit amount="-15" />
	<choice>
		<text>Continue...</text>
	</choice>
    <text>You find the remains of a mighty battle directly in front of your ship. You harvest as much scrap as you can.</text>
	<autoReward level="HIGH">scrap_only</autoReward>
</event>
Also, I did this without any tutorials. Couldn't seem to find any on coding this stuff.
User avatar
Kieve
Posts: 944
Joined: Tue Sep 18, 2012 2:21 pm

Re: Working on a simple mod to start, need some help with co

Post by Kieve »

The trick is, you need to contain each step with a new <event> tag. Have a look at the "Tutorial" code in events.xml and it'll give you a fairly solid idea of what's necessary for event structure. FTLwiki also has a great deal of important information. I suggest reading through the "Modding Guide" for most of the basics, if you haven't done so already - in particular the Event Structure page.

I tried my hand at fixing the event - note the use of 'hidden="true"' tags in the choices. This keeps the scrap amount from showing up at the end of each text choice. Without it, your prompts would look something like "Continue... [15 Scrap]"

Code: Select all

<!-- Gumpmod mod -->

<event name="START_GAME">
	<text>The data you carry is vital to the remaining Federation fleet. You'll need supplies for the journey, so make sure to explore each sector before moving on to the next. But get to the exit before the pursuing Rebel fleet can catch up! The rebel fleet has been delayed due to some inner rebellions.</text>
	<modifyPursuit amount="-15"/>
	<choice hidden="true">
		<text>Continue...</text>
		<event>
			<text>You find the remains of a mighty battle directly in front of your ship. You harvest as much scrap as you can.</text>
			<autoReward level="HIGH">scrap_only</autoReward>
		</event>
	</choice>
	<choice hidden="true">
		<text>Continue...</text>
		<event>
			<text>Just as you're about to commit your first FTL jump, another partially destroyed ship drifts into your path. You harvest as much scrap as you can.</text>
			<autoReward level="HIGH">scrap_only</autoReward>
		</event>
	</choice>
	<choice hidden="true">
		<text>Continue...</text>
		<event/>
	</choice>
</event>

<event name="START_BEACON">
	<text>Welcome to a new sector! Get to the exit beacon and jump to the next sector before the pursuing Rebels catch you!</text>
	<modifyPursuit amount="-15" />
	<choice hidden="true">
		<text>Continue...</text>
		<event>
			<text>You find the remains of a mighty battle directly in front of your ship. You harvest as much scrap as you can.</text>
			<autoReward level="HIGH">scrap_only</autoReward>
		</event>
	</choice>
</event>
ForrestGump wrote:Also, I did this without any tutorials. Couldn't seem to find any on coding this stuff.
Didn't do too badly at all. Events are really sensitive - a single misplaced tag can cause fatal crashes on loading, so there's really no margin for error with them and makes it a real pain in the ass to troubleshoot.
ForrestGump
Posts: 5
Joined: Sat Nov 17, 2012 12:11 pm

Re: Working on a simple mod to start, need some help with co

Post by ForrestGump »

Thanks for the fixes information and advice. :)

I didn't know about the wiki or anything. Thanks a lot! Now I got some stuff to read, appreciated muchly. :)
ForrestGump
Posts: 5
Joined: Sat Nov 17, 2012 12:11 pm

Re: Working on a simple mod to start, need some help with co

Post by ForrestGump »

The 2nd event of finding scrap at the start of the game doesn't appear to work but the code is stable and everything else works fine. I'm reading around and looking at the code and stuff but I haven't figured it out yet.

Code: Select all

<text>Just as you're about to commit your first FTL jump, another partially destroyed ship drifts into your path. You harvest as much scrap as you can.</text>
The one that starts here currently will not display in the game. Using the code you gave me. Let me know if you figure it out before I do, thanks a lot!
Post Reply