Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.

In the meantime please join the new Discord Server!

If you have any questions please e-mail me through the Platinum Arts website.

Learn recipe

Having issues not related to a specific Sandbox game mode? Get help here!
Please also read the rules for support when posting support requests.
Failure to comply with the forum rules may result in your topic being locked without resolution.
Locked
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Learn recipe

Post by wildflower »

I have created a simple recipe for a health-potion using the guide in the wiki, the recipe works fine if it's in the /recipes folder, but how do I learn a unknown recipe?

btw. This is how my my recipe looks so far:

Code: Select all

r_recipe_flags $RECIPE_KNOWN //we know the recipe at the start
r_recipe_add_ingredient 4 2 // 2 x healing plant
r_recipe_add_catalyst 7 1 // 1 x mortar and pestle
r_recipe_add_product 11 1 // 1 x health potion
I assume that I can use something like "RECIPE_UNKNOWN" for recipes that the player haven't learned yet?
User avatar
Captain_Ahab
Member
Member
Posts: 98
Joined: June 10th, 2009, 5:12 pm
Name: Richard

Re: Learn recipe

Post by Captain_Ahab »

Its a flag, right? I would think that, 'true' means the recipe is known, but a 'false' means it is unknown

of course, scripting isn't my strong point.......
Image
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Learn recipe

Post by Hirato »

wildflower wrote:I have created a simple recipe for a health-potion using the guide in the wiki, the recipe works fine if it's in the /recipes folder, but how do I learn a unknown recipe?

btw. This is how my my recipe looks so far:

Code: Select all

r_recipe_flags $RECIPE_KNOWN //we know the recipe at the start
r_recipe_add_ingredient 4 2 // 2 x healing plant
r_recipe_add_catalyst 7 1 // 1 x mortar and pestle
r_recipe_add_product 11 1 // 1 x health potion
I assume that I can use something like "RECIPE_UNKNOWN" for recipes that the player haven't learned yet?
No, it doesn't work that way. I'd recommend reading up on bitwise operations and logic.
In short you'd simply neglect to use the RECIPE_KNOWN flag when you define the flags for your recipes.
r_learn_recipe basically just switches that flag on
This is not a url, clicking it is pointless
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Re: Learn recipe

Post by wildflower »

@Hirato

Thank you, once again, just what I needed to know :D
And you are right... I probably should get better acquainted with bitwise operations and logic.

btw. I was looking at the menu.cfg under the guitab "Crafting", and I can't see there's a way to name a recipe?

I thought of adding something like :

Code: Select all

				if (& (r_recipe_flags_get) $RECIPE_KNOWN) [
					if ( = $i 0) [
						guibutton "Create health Potion (Uses 2 healing plants)" [r_use_recipe @i]
					]
				]
I know it's a hack-job, but I hope you get the general idea.
Hirato
Developer
Developer
Posts: 689
Joined: May 30th, 2009, 1:23 pm
IRC Username: hirato

Re: Learn recipe

Post by Hirato »

yeah.. I didn't get that far yet
This is not a url, clicking it is pointless
chocolatepie33
Support Team
Support Team
Posts: 2458
Joined: April 27th, 2010, 5:31 pm
IRC Username: CP

Re: Learn recipe

Post by chocolatepie33 »

Bitwise operators:

http://quadropolis.us/node/3171

@hirato: wow, that's kinda funny :)
Julius wrote:Contribute to http://www.opengameart.org NOW!
Save the wiki!
User avatar
wildflower
Member
Member
Posts: 76
Joined: August 11th, 2011, 5:10 am
Name: Sandie

Re: Learn recipe

Post by wildflower »

chocolatepie33 wrote:Bitwise operators:

http://quadropolis.us/node/3171

@hirato: wow, that's kinda funny :)
Like many mathematical related things, I get the concept but have no idea how to apply it in actual code.
My husband have tried to explain it to me several times, and I think it's where he gets his gray hairs.

@hirato
No problem, I'll just throw this in menus.cfg for now:

Code: Select all

		guitab "Crafting"
		loop i (r_num_recipe) [
			r_select_recipe $i [
				if (& (r_recipe_flags_get) $RECIPE_KNOWN) [
					if ( = $i 0) [
						if ( < (r_get_amount player 4) 2) [ // do we have at least two healing plants?
							guitext "Health Potion - You need 2 healing plants to make a health potion"
						] [
							guibutton "Create health Potion - Uses 2 healing plants" [r_use_recipe @i]
						]
					]
					if ( = $i 1) [
						if ( < (r_get_amount player 4) 2) [ // do we have at least two mana mushrooms?
							guitext "Mana Potion - You need 2 mana mushroom to make a mana potion"
						] [
							guibutton "Mana Potion - Uses 2 mana mushrooms" [r_use_recipe @i]
						]
					]
				]
			]
		]
Locked