It looks like you're new here. If you want to get involved, click one of these buttons!
Hello all, I just found IPP3 recently and am diving right into making generators for some homebrew items as a learning project. The items can reward variable xp, can be used for enchanting effects, and/or can be used to learn spells.
As I went about making the initial framework, I made a prompt for the "tier" of item to be generated, including Random in case I wanted a little extra chaos. I ran into an issue, however, when trying to tie the answer to the prompt into my main expression for generating a result. I can set my "Echo" variable so it either works correctly if the prompt returns Random OR a tier name, but not both. Setting Echo like I do below calls the table associated with the name, which works great for Random, but prematurely generates the xp and then returns (missing) for the second result if the prompt returns any of the named tiers. Changing the way I initially set Echo so it doesn't immediately call a table breaks Random, as it will then list the result as [Random, Iron, Common, Common, Uncommon, Rare], or what have you.
.
.
`Prompt: Echo Tier {Random|Iron|Bronze|Silver|Gold|Mythril/Adamant|Exaltant}Random
Table:TheBiggun
set: Echo =[@{$prompt1}]
{Echo}, [@{Echo}], [@Rarity], [@Rarity], [@Rarity], [@Rarity]
Table: Iron
{10} xp
Table: Bronze
{20} xp
Table: Silver
{30} xp
Table: Gold
{40} xp
Table: Mythril/Adamant
{50} xp
Table: Exaltant
{60} xp
Table: Rarity
76: Common
22: Uncommon
2: Rare
Table: Random
Iron
Bronze
Silver
Gold
Mythril/Adamant
Exaltant`
.
.
.
.
Then I tried using a When/Do conditional, but I'm having a lot of trouble with that one. Even almost exactly copying the expression from the Random Treasure generator that comes with IPP3 returns a lot of blank results or often lists (missing) in the result. Here's my attempt at that:
.
.
`Prompt: Echo Tier {Random|Iron|Bronze|Silver|Gold|Mythril/Adamant|Exaltant}Random
//Table: TreasureProxy
//[when]{$prompt1}=Random[do]{!CRValue=={1d30}}[else]{!CRValue=={$prompt1}}[end][@TreasureByCR]
Table: PromptProxy
[when]{$prompt1}=Random[do] {!Echo==[|Iron|Bronze|Silver|Gold|Mythril/Adamant|Exaltant]} [else] {!Echo=={$prompt1}}[end][@TheBiggun]
Table: TheBiggun
{Echo}, [@{Echo}], [@Rarity], [@Rarity], [@Rarity], [@Rarity]
Table: Iron
{10} xp
Table: Bronze
{20} xp
Table: Silver
{30} xp
Table: Gold
{40} xp
Table: Mythril/Adamant
{50} xp
Table: Exaltant
{60} xp
Table: Rarity
76: Common
22: Uncommon
2: Rare
Table: Random
Iron
Bronze
Silver
Gold
Mythril/Adamant
Exaltant `
.
.
.
.
I have tried adding and deleting white space, I have tried adding and deleting the $ when referencing the variables since it used to be relevant but is less so now according to my reading, but now I turn to these forums for guidance.
Based on what I'm trying to accomplish (have prompt, list prompt answer, list results from table directly tied to prompt answer), what should I be doing differently? Am I even on the right path here? I'm not a programmer by any stretch, but I am having fun learning this scripting language.
Comments
When you do this:
{!Echo==[|Iron|Bronze|Silver|Gold|Mythril/Adamant|Exaltant]}
I think those should be square brackets instead of curly ones, and you don't need the exclamation point. This works:
Ah! Thank you, it worked! Looking at the docs again, the example for the When command does use square brackets in the Do section. Is that a consistent rule, then?
It still returns a blank line for no reason at times, did you get that as well?
Regardless, thank you for your fast response!
I think the general rule is that curly brackets are for math and variables. If it's not those things, it should be square brackets. To be honest I always just go check a working generator to remind myself of the formats for things though.
I'm not getting any blank lines. My guess is you have a line with a space after the first table so it sometimes selects that line instead of the one with the actual content.
More differences between braces and brackets:
{stuff==prompt1}
sets the variable stuff equal to the value of prompt1.[stuff==prompt1]
sets the variable stuff equal to the text 'prompt1'.[stuff=={prompt1}]
sets the variable stuff equal to the value of prompt1.There's no harm in writing
{10} xp
for example, but the braces aren't necessary in your example.10 xp
works fine because the mathematical evaluation of {10} yields the text '10'.When you get seemingly empty results from a table that shouldn't return empty results, look for spaces on an otherwise blank line. Consider these two examples:
Table x1 says Hello roughly half the time, and returns "nothing" the rest of the time. Table x2 says Hello every time even though they look identical. The difference is that the blank line after Hello in x1 has a space, so IPP considers it a table of two entries. The blank line after Hello in x2 doesn't have a space, so IPP considers it a table of one entry. It's easy to wind up with unexpected spaces. The editor likes adding spaces, either to fill out a line when you type something past the last character on the line, or to match the indentation of the line above.
Although EndTable is never strictly necessary, it can help avoid this problem. This example leaves no doubt where the end of the table is:
One more example:
If the line between Hi and Hello has no content, table x4 says either Hi or Hello every time. If that seemingly empty line has a space in it, x4 shows Hi about a third of the time, Hello about a third of the time, and apparently nothing for the rest. That's because a space is content that becomes another table entry, but a truly empty line (not even a space) doesn't get treated as a table entry.