• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Need help correcting and/or changing code.

Noisy Pants

Refugee
Now that boxes of bullets can be made, I am trying to make it possible to make boxes of bullets for this sniper turret mod. I believe this code to be correct, yet when I open the box of bullets nothing happens. I think my problem is the first property, "ammoBundleMaster", I'm not sure what to do though.
 

<item name="Box of 50 Caliber Ammo">
<property name="Extends" value="ammoBundleMaster"/>
<property name="CustomIcon" value="ammo762mmBulletBall"/>
<property name="CustomIconTint" value="a0a0ff"/>
<property name="EconomicValue" value="2200"/>
<property name="UnlockedBy" value="perkAdvancedEngineering"/>
<property class="Action0">
<property name="Create_item" value="50 Caliber Ammo"/>
<property name="Create_item_count" value="100"/>
</property>
</item>


The other issue is the localization text.

Key,File,Type,UsedInMainMenu,NoTranslate,english
Boxof50CaliberAmmo,items,Ammo,,,Box of 50 Caliber Ammo (100)
I believe that to be correct yet it is not working.
 

box of 50.jpg

 
Spaces are the demons of xml. Chances are they are the culprit. Same for localization. If your xml entry has spaces, your localization wont work.

 
Try to use resourceRockSmallBundle to extend from instead. (used that to pack and unpack clay and that works fine)

in localization I found the format:

Key,Source,Context,English
Thing,items,Item,ThingDescription

to work well so:

Key,Source,Context,English
Boxof50CaliberAmmo,items,Ammo,Box of 50 Caliber Ammo (100)


Should work I believe.

 
Put double quotes around the localization name, even if you don't think you need it.

Key,Source,Context,English
Boxof50CaliberAmmo,items,Ammo,"Box of .50 Caliber Ammo (100)"



Also, just being pedantic, but make it .50, not 50.  50 caliber would be a deck-mounted gun on a battleship, at least.  But what do I know, maybe your sniper turret really is that big?  I'd use it! :)

The main problem is definitely the spaces, though.  Never use spaces in your items name= field.  Let localization do it.  And try to stick to their conventions, so its easy to tell what it is in case you want to add .50 AP or .50 HP

<item name="ammo50calballBox">
<property name="Extends" value="ammoBundleMaster"/>
<property name="CustomIcon" value="ammo762mmBulletBall"/>
<property name="CustomIconTint" value="a0a0ff"/>
<property name="EconomicValue" value="2200"/>
<property name="UnlockedBy" value="perkAdvancedEngineering"/>
<property class="Action0">
<property name="Create_item" value="ammo50calball"/>
<property name="Create_item_count" value="100"/>
</property>
</item>


Key,Source,Context,English

ammo50calballBox,items,Ammo,"Box of .50 Caliber Ammo (100)"

ammo50calball,items,Ammo,".50 Caliber Ammo"

And for this to all work, you'll also need to change your original item name for 50 cal ammo

<item name="ammo50calball">

<!--  whatever code you already have here -->

</item>

Remember that the 1st column in localization must exactly match your <item name="">

You CAN double quote that 1st column if you really want to include spaces, but you'll hate it later if you do.  Trust someone who's made that mistake.

 
Last edited by a moderator:
Put double quotes around the localization name, even if you don't think you need it.

Key,Source,Context,English
Boxof50CaliberAmmo,items,Ammo,"Box of .50 Caliber Ammo (100)"



Also, just being pedantic, but make it .50, not 50.  50 caliber would be a deck-mounted gun on a battleship, at least.  But what do I know, maybe your sniper turret really is that big?  I'd use it! :)

The main problem is definitely the spaces, though.  Never use spaces in your items name= field.  Let localization do it.  And try to stick to their conventions, so its easy to tell what it is in case you want to add .50 AP or .50 HP

<item name="ammo50calballBox">
<property name="Extends" value="ammoBundleMaster"/>
<property name="CustomIcon" value="ammo762mmBulletBall"/>
<property name="CustomIconTint" value="a0a0ff"/>
<property name="EconomicValue" value="2200"/>
<property name="UnlockedBy" value="perkAdvancedEngineering"/>
<property class="Action0">
<property name="Create_item" value="ammo50calball"/>
<property name="Create_item_count" value="100"/>
</property>
</item>


Key,Source,Context,English

ammo50calballBox,items,Ammo,"Box of .50 Caliber Ammo (100)"

ammo50calball,items,Ammo,".50 Caliber Ammo"

And for this to all work, you'll also need to change your original item name for 50 cal ammo

<item name="ammo50calball">

<!--  whatever code you already have here -->

</item>

Remember that the 1st column in localization must exactly match your <item name="">

You CAN double quote that 1st column if you really want to include spaces, but you'll hate it later if you do.  Trust someone who's made that mistake.
stample, thank you very much - i've learned more about the localization; everything works now! 🙂

no spaces.jpg

 
Noisy Pants, I feel like we've been here before. I thought you already learned how to do this localization thing right back when you worked on your electric eel trap mod. Telric was right - spaces are allowed in text inside localization.txt, but not in the item names inside xml and localization.txt. That's a big NO NO.

 
Last edited by a moderator:
Noisy Pants, I feel like we've been here before. I thought you already learned how to do this localization thing right back when you worked on your electric eel trap mod. Telric was right - spaces are allowed in text inside localization.txt, but not in the item names inside xml and localization.txt. That's a big NO NO.
that's the CRAZY thing, i've used spaces so i thought i could
example:

<config>
<append xpath="/blocks">

<block name="Electric Eel Trap">
<property name="CreativeMode" value="Player"/>
<property name="CustomIcon" value="Electric Eel Trap"/>
<property name="Class" value="Liquidv2"/>
<property name="Material" value="Mwater"/>
<property name="Shape" value="Water"/>
<property name="Mesh" value="water"/>
<property name="DescriptionKey" value="ElectricEelTrapDesc"/>
<property name="Model" value="water_full"/>
<property name="Texture" value="223"/>
<property name="Map.Color" value="0,0,0"/>
<property name="Map.Color" value="0,0,0"/>
<property name="BuffsWhenWalkedOn" value="buffShocked"/>
<property name="BuffChance" value="1"/>
<property name="Path" value="solid"/>
<property name="Group" value="Tools/Traps,Science,Chemicals,CFChemicals"/>
<property name="EconomicValue" value="150"/>
<property name="SortOrder1" value="70g0"/>
<property name="FilterTags" value="fdecor,felectrical,ftraps"/>
</block>

</append>
</config>


the localization file
 

Key,File,Type,UsedInMainMenu,NoTranslate,english
ElectricEelTrap,blocks,Block,,,Electric Eel Trap
ElectricEelTrapDesc,blocks,Block,,,"Unlock crafting at level 3 Advanced Engineering.\nMust be utilized in a container or moat of cube blocks of your choice."

eeltrap.jpg

 
<config>
<append xpath="/blocks">

<block name="Electric Eel Trap">
<property name="CreativeMode" value="Player"/>
<property name="CustomIcon" value="Electric Eel Trap"/>
<property name="Class" value="Liquidv2"/>
<property name="Material" value="Mwater"/>
<property name="Shape" value="Water"/>
<property name="Mesh" value="water"/>
<property name="DescriptionKey" value="ElectricEelTrapDesc"/>
<property name="Model" value="water_full"/>
<property name="Texture" value="223"/>
<property name="Map.Color" value="0,0,0"/>
<property name="Map.Color" value="0,0,0"/>
<property name="BuffsWhenWalkedOn" value="buffShocked"/>
<property name="BuffChance" value="1"/>
<property name="Path" value="solid"/>
<property name="Group" value="Tools/Traps,Science,Chemicals,CFChemicals"/>
<property name="EconomicValue" value="150"/>
<property name="SortOrder1" value="70g0"/>
<property name="FilterTags" value="fdecor,felectrical,ftraps"/>
</block>

</append>
</config>

In that example,  you have a description key  property that directs to a localization without spaces. The name will be displayed like it is in the xml if no localization is found for it. In this case, they just happened to be the same thing.

 
Last edited by a moderator:
In that example,  you have a description key  property that directs to a localization without spaces. The name will be displayed like it is in the xml if no localization is found for it. In this case, they just happened to be the same thing.
ah - okay, wow! spaces are such a.... interesting detail to have to pay attention to - lol

 
Back
Top