Topic: Eh? Can't get code to work  (Read 861 times)


ElementalSon

« on: December 10, 2018, 02:43:41 AM »
Hey all. Having trouble getting some code to work, specifically cooking code. I've created a test arrow item and had it work fine, so I'm confused as to where my issue is here.

I have two problems that seem to come up. The first is a menudef_ problem. Despite only having one menudef_ file for this submenu, after editing and saving the code for any reason,
it sometimes shows up twice in game. The code is:

Code: [Select]
.Liam's Foods. -Z- *COOKERY*

The filename is menudef_Liam's Foods.txt
I've also tried saving it as menudef_Liam's New Foods.txt and menudef_liams foods.txt
This doesn't seem to make a difference.

In game, it shows up like this:  

(Note - I reduced the quality to minimize filesize)

The second issue I have is to do with the submenu contents. My submenu consists of the following item/code:

Code: [Select]
[SUBMENU_START:Liam's Foods]

.Pemmican. "Berries" *COOKERY* #5# /20/ \2h\ %20% |2| [patch:9] :148:
{Berries} #2# [roast] [patchwise] [remove]
{Raw meat} #2# [roast] [patchwise] [remove]
{Knife} <Broad knife> '+for cutting up meat and crushing berries'
[SPOILAGE_DAYS:100]
[CARB:2]
[FAT:4]
[PROTEIN:2]
[WEIGHT:0.5]
[PRICE:2]
[TILEGFX:bc-clay]

[SUBMENU_END:Liam's Foods]

I've been through it as closely as I can. I've tried re-naming it as above, I've tried re-writing the code entirely in a new Notepad++ file, I've tried copying code for items that I do know works in game within my SUBMENU_START header and footer and had it not work. The submenu contents in game are blank. The result in game is this:

I cannot for the life of me figure out how I've buggered this one up. Please help!

ElementalSon

« Reply #1 on: December 10, 2018, 02:47:13 AM »
Sorry, addendum to my last:
 
Regarding this code:
Code: [Select]
[SUBMENU_START:Liam's Foods]

.Pemmican. "Berries" *COOKERY* #5# /20/ \2h\ %20% |2| [patch:9] :148:
{Berries} #2# [roast] [patchwise] [remove]
{Raw meat} #2# [roast] [patchwise] [remove]
{Knife} <Broad knife> '+for cutting up meat and crushing berries'
[SPOILAGE_DAYS:100]
[CARB:2]
[FAT:4]
[PROTEIN:2]
[WEIGHT:0.5]
[PRICE:2]
[TILEGFX:bc-clay]

[SUBMENU_END:Liam's Foods]

I've also tried removing "Berries", :148: and [TILEGFX:bc-clay] at various points; I'm aware there's overlap / not necessary elements in this. At this point I've left all 3 in because nothing I am doing seems to get this to work correctly.

- Liam

Privateer

« Reply #2 on: December 10, 2018, 03:07:40 AM »
I'll try to help. First add an additional line (carriage return) to the end of your menudef file.
For cooking you don't define an actual game item with "item". Cooking truly allows item creation based on the added nutrition of the items consumed in the task.

Not tested but the below code should work
Code: [Select]
.Pemmican.  (5)  *COOKERY*  /20/ \2h\ %20% |2| [patch:9]
{Berries} #2# [roast] [patchwise] [remove]
{Raw meat} #2# [roast] [patchwise] [remove]
{Knife} <Broad knife> '+for cutting up meat and crushing berries'
[SPOILAGE_DAYS:100]
[PRICE:2]
[TILEGFX:bc-clay]

These tags don't apply as values are derived from the inputs
[CARB:2]
[FAT:4]
[PROTEIN:2]
[WEIGHT:0.5]


ElementalSon

« Reply #3 on: December 10, 2018, 03:15:25 AM »
@Privateer

It does indeed work - so the key changes were removing the "" tag, adding how many should be created (despite the inclusion of [patch:9]), removing [CARB:2],[FAT:4],[PROTEIN:2] and [WEIGHT:0.5], as well as the indents in the code.

Thank you so much for your help.

Any advice re the double submenu showing up? I added the additional CR but it's still doubled.

Thanks

- Liam.

Privateer

« Reply #4 on: December 10, 2018, 03:47:00 AM »
Extra carriage returns in the menudef usually resolves the double name (odd occurrence).
As well on the top line of the original code you had this #5# (which may break the code) but I took to be a number to be created as you had 4 lbs of materials and you were trying for an end weight of .5 I assumed you meant #5# to be 5 ~ .5 lb items. patch for larger batches I guess. You could remove (5) and make one item with a patch of 9.

ElementalSon

« Reply #5 on: December 10, 2018, 04:00:32 AM »
@Privateer

Re menudef_ - no worries, thanks for the advice. I'll see if I can find another way around it. Worst case scenario, always got a clean backup of URW.

Re .Pemmican. - yeah, correct, 5x 0.5lbs items was the aim - thank you. I'm trying to compile a list of my coding goofs so I can put them as comments. Terrible memory, so every bit of advice helps.

Cheers man, you've turned my day from very frustrating to pretty good. Thanks again!

Privateer

« Reply #6 on: December 10, 2018, 04:26:22 AM »
Glad to help.. Pretty sure the double is because the game sees something on the line after last * Try pasting this to your menu file

Code: [Select]
// Here's a try at your menu file

.Liam's Foods. -Z- *COOKERY*


//end

Frostbit

« Reply #7 on: December 10, 2018, 10:04:46 PM »
I remember having this same issue back when I first started learning to mod and found that whenever I made a change to my menudef, diy and cookery files it automatically made a hidden backup which was screwing up all of my menus by making duplicates. I deleted those and it cleaned everything right up.
« Last Edit: December 10, 2018, 10:51:52 PM by Frostbit »

ElementalSon

« Reply #8 on: December 11, 2018, 12:07:38 AM »
@Privateer  - Yep, that seems to have worked. Thanks - double CR and a comment at the end is a fix. Good to know.

@Frostbit - Hey, thanks for the heads' up - I've just looked at it for an item file I made and found a hidden backup. That makes a lot of sense - I was combing through the unhidden files before going 'why!? HOW!? There's only one def of it', so that is something I'll check for from now on. You guessed it though - brand new to this, so thanks for the help.

If you guys don't mind, I have another question. I've written a piece of code for a pickaxe for mining quartz. The code executes fine, all of the attributes are correct, it shows up in the right inventory slot and it uses all the intended recipe ingredients. The difficulty I'm having with it is I can't get it visible when dropped on the ground. I've created a new tile for it, saved it in the right spot and double checked the code. Not sure what the issue is. Any help would be appreciated - code and bc below:

Code: [Select]
[SUBMENU_START:Quartz production]

.Stone pickaxe. "Firewood" [effort:2] [phys:arms,hands] *CARPENTRY* %50% /3h/
{Wooden stake} (1) [remove] '+for the haft'
{Stone} (1) [remove] '+to shape the pick head'
{Cutting weapon}
{Tying equipment} (2) [remove]
{Fire} '+to harden the timber'
[NAME:Stone pickaxe]
[BLUNT_ATTACK:1]
[EDGE_ATTACK:1]
[POINT_ATTACK:3]
[AD_CLASS:3/1]
[WEIGHT:4]
[SKILL:Axe]
[PRICE:10]
[TYPE:tool]
[TILEGFX:bc-pickaxe]

[SUBMENU_END:Quartz production]

//end - all works except the graphic??? test and adjust tomorrow.

The tile is saved as bc-pickaxe.png, it's in the truetile folder, it's 34x34 pixels and 32 bit (same as the vanilla files). I've tried it on both a purely transparent background, and on a coloured background like the other tiles. Note it was created from scratch, not an edited vanilla file re-saved.

Thoughts?

Privateer

« Reply #9 on: December 11, 2018, 12:36:52 AM »
Couple things;
1) For item creation with new image(s), try to have the image created and in place both in the folder and the task (text) before starting the game.
2) Items will only take the image they had when it was created, eg using "Firewood" without an image will show firewood, updating the task with an image will NOT change the previously created items.
3) F9 can be used in game to refresh images in game, so you can edit images and see how they look after creation

I would also move the image tag up to just below the name tag but that's just me I don't think it should break anything.

ElementalSon

« Reply #10 on: December 11, 2018, 01:11:34 AM »
@Privateer - solved it again, man - thank you. F9 was all it needed. Might re-size it though.

Noted on the image tag move - thanks.

« Last Edit: December 11, 2018, 01:20:32 AM by ElementalSon »