Talk:Nature's Gift

From Terraria Wiki
Jump to navigation Jump to search

Visual Distinction

Both Nature's Gift and the Water Tome are visually distinct from grass and books, respectively. I'll try and get a screenshot of a Nature's Gift tomorrow morning. For now, bed.Thursday 03:49, 23 May 2011 (UTC)

Not grass, jungle roses. Roses are red, and Nature's Gift is blue. --Barhandar 05:55, 23 May 2011 (UTC)

Hardcore Mode

So are these going to be worthless in hardcore mode? I would assume so. Would be cool if instead it gave a different bonus though. Like slight mana/health regen.

Hardcore? hardcore is the difficulty which you die permanently so it wouldnt do anything. You probably mean hardmode but it still doesn't do anything to it and you can craft mana flower which is very good for mages.

Trivia point: Only accessory harvested directly from environment?

Is this (and for vanity, the Jungle Rose) the only accessory -- or even the only wearable item -- that is obtained directly by harvesting an object in world? (I exclude pot drops for obvious reasons) --MentalMouse42 (talk) 20:00, 3 October 2019 (UTC)

Incorrect profit tip

The page claims that a Mana Flower sells for 5 GC, but the real sell price is 1 GC. I looked into the source and the data templates/other things used confused me beyond these simpler templates that I'm used to, so I'm uncertain the problem and how to correct it. 2057clones (talk) 15:13, 4 February 2021 (UTC)

I'll try to break it down, and insert some linebreaks and indentations for better readability of the paragraph:
A [[Mana Flower]] can be sold for
{{coin|
	{{#vardefineecho:result-sell|
		{{iteminfo|Mana Flower|sell|raw=y}}
	}}
}},
while its ingredients, one Nature's Gift and one [[Mana Potion]], only sell for
{{coin|
	{{#vardefineecho:ings-sell|
		{{recipes/extract|result=Mana Flower|mode=ingredients-sell}}
	}}
}}
together. Therefore, it is
{{percent|
	{{#var:result-sell}}/{{#var:ings-sell}} -1
}}
more profitable to craft spare Nature's Gifts into Mana Flower before selling them.
The parameter of the first {{coin}} template call can be described as follows: Take the result of {{iteminfo|Mana Flower|sell|raw=y}} – 50000 –, store it to a variable named result-sell, and pass it to {{coin}} ({{coin|50000}}), resulting in an output of 5 GC. This way, we stored the result of the dynamic data fetch via {{iteminfo}} and displayed it at the same time, in one go.
The second {{coin}} template call is similar: Take the result of {{recipes/extract|result=Mana Flower|mode=ingredients-sell}} – 5450 –, store it to a variable named ings-sell, and pass it to {{coin}} ({{coin|5450}}), resulting in an output of 54 SC50 CC.
The {{percent}} call now receives the quotient of the two variables defined above, subtracted by 1, as input: {{percent|50000/5450 -1}}. The result of the expression is 9.1743119266055 -1 = 8.1743119266055, and the template displays that as 817.43%.
(Note that the {{percent}} template call used to be written with {{#expr:}} and a literal percent sign at the end, but I changed it to {{percent}}, because it improves readability and facilitates easier translation of the page. Different languages use different percentage formats (e.g. in Turkish, the percent sign is in front of the number; see Template:Percent), and with {{percent}}, the translating editor doesn't need to worry about the formatting as the template takes care of that.)


Now onto the original error. {{iteminfo}} has two modes: "normal" and "raw", toggled via the |raw= parameter. In "normal" mode, the template automatically applies some "intuitive" formatting to the requested value, in order to display it properly in article text. For instance, {{iteminfo|Swiftness Potion|buffTime}} wraps the buff duration in {{duration}} (which includes automatic translation): 8 minutes. This isn't always useful, however – e.g. when we want to store the value in a variable so we don't have to perform another {{iteminfo}} call with the same parameters (a somewhat performance-intensive operation, and since it's a duplicate, it's avoidable), like in our paragraph above. For that reason, the "raw" mode can be used to return the "raw" numerical value as it is in Terraria's source code, with no formatting applied to it whatsoever. This can be seen in {{iteminfo|Swiftness Potion|buffTime|raw=y}}: 28800 – we get the "raw" number of ticks[1].
{{iteminfo}} allows using aliases for the different stats. For instance, we could write {{iteminfo|Swiftness Potion|buff duration}} (which is actually preferable because of its better readability), {{iteminfo|Swiftness Potion|buffduration}}, or {{iteminfo|Swiftness Potion|buffDuration}} instead of {{iteminfo|Swiftness Potion|buffTime}}, all without a change in output. However, as described at the bottom of Template:Iteminfo § Usage, these aliases do not work in raw mode. This is the crucial error that is present in {{iteminfo|Mana Flower|sell|raw=y}}sell is an alias, not an original variable name (can be seen in the table)! In fact, there isn't even an original variable name for an item's sell value, because that is not stored in Terraria's code; instead it is simply determined by dividing the buy price by 5. Due to the way {{iteminfo}} is coded, what happens is that requesting sell causes it to fetch the buy price from the game's code, but not divide it by 5 then (because sell is not recognized as an original variable name) and return it as-is. As always in software development, some design choices just have to be made at the beginning, and sometimes, when they reveal themselves to be hindering in the further development and are worked around somehow, you end up with a system that has somewhat unintuitive parts in it, like in this case: The template gives unexpected output (instead of nothing or an error) when an alias is used in raw mode, at least for sell values.


So, what to do, how to fix? One possibility would be to retrieve the raw buy price and divide it by 5 ({{#expr:{{iteminfo|Mana Flower|value|raw=y}}/5}}{{#expr:50000/5}}, resulting in 10000), but this is quite awkward and rather hard to read (and understand; the division by 5 in particular can easily seem arbitrary to some). For this exact reason, because there were a lot of these constructs used on Guide:Making money, a handy helper template was developed: {{sell expr}}. It is originally intended for combining several sell values in more complex expressions, but it's fine to use it as a way to display the raw sell value of a single item. {{sell expr|raw=y|Mana Flower}} gives 10000 – success! I already changed it.
I know this is a lot, but I hope it helped you a bit. I understand that things may be hard to grasp at times (have been and still am in that position myself often), so please ask if you have questions. There might be other people with the same questions, and me and others would be happy to assist! --Rye Greenwood (talk) 21:26, 4 February 2021 (UTC)
  1. A tick is a time unit countable by the software. Most of Terraria's updating logic happens every tick. A tick has the length of 1/60th of a second, hence there are 60 ticks in a second and 3600 ticks in a minute.