Keyboard Shortcuts
Likes
- Tablesmith
- Messages
Search
Mysterious Error
#error
I am running into an odd error.
Summon Monster I ( ***ERROR on line 891 of table 'Spells' - Group 'Creatures.SumMon1' not found. *** )Here is the crux.? I can roll on the attached table and never get an error - there are not 891 lines in that table either. For testing, I am calling it from another table (in another folder) with a simple: :Start 1, [Spells.Wizard1] What am I missing??? |
Re: Arrays to track count?
开云体育There is a special version of DSAdd that does not give you a printed value… DSAddNR~ NR for No Return value ? Vance ? Sent from for Windows 10 ? From: ErolB1 via groups.io
Sent: Tuesday, April 6, 2021 5:59 PM To: [email protected] Subject: Re: [TableSmith] Arrays to track count? ? In the :AddItem group you're using DSAdd, which returns the index of the entry added. You need to use DSAddNR which does not return any value. ? (I'd forgotten about that when I gave the example using DSAdd earlier.) ? Or you could get clever and replace {DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%} ? with ? |NumRecs={DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%}| ? which will save you from having to do |NumRecs={DSCount~Treasure}| in the :Display group. ? ? Erol K. Bayburt ErolB1@... ? On 4/6/2021 4:37 PM, Otaku Smurf wrote: > Ok, I am just working a small test before I toss in the really big > random table.? When I run this, I get an output like: > 1 2 Emerald 3 1500 > Ruby 1 2500 > > The first 1 and 2 are the index values. > > How can I stop those from being displayed?? I cannot for the life of me > figure out where I am "printing" the index numbers.? Here is my code: > > #Declare Data Set > %Treasure%, 1 > #Declare Variables > %TreasureType%, 0 > %Quantity%, 0 > %GoldValue%, 0 > %NumRecs%, 0 > %Index%, 1 > %SavedIndex%, 0 > :Start > 1, {DSCreate~Treasure,TreasureType,NONE,Quantity,0,GoldValue,0} > _{Loop~4,[Generate1]} [Display] > :Generate1 > 1,|TreasureType=Diamond||Quantity=1||GoldValue=5000| [AddItem] > 2,|TreasureType=Ruby||Quantity=1||GoldValue=2500| [AddItem] > 3,|TreasureType=Emerald||Quantity=1||GoldValue=500| [AddItem] > 4,|TreasureType=Sapphire||Quantity=1||GoldValue=750| [AddItem] > 5,|TreasureType=Topaz||Quantity=1||GoldValue=200| [AddItem] > :AddItem > 1,|SavedIndex={DSFind~Treasure,0,TreasureType=%TreasureType%}| > _{If~%SavedIndex%<0? > _{DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%}/ > _{DSSet~Treasure,%SavedIndex%,Quantity,{Calc~{DSGet~Treasure,%SavedIndex%,Quantity}+%Quantity%}} > _{DSSet~Treasure,%SavedIndex%,GoldValue,{Calc~{DSGet~Treasure,%SavedIndex%,GoldValue}+%GoldValue%}}} > :Display > 1, |Index=1||NumRecs={DSCount~Treasure}| > _{Loop~%NumRecs%, > _|TreasureType={DSGet~Treasure,%Index%,TreasureType}|%TreasureType% > _|Quantity={DSGet~Treasure,%Index%,Quantity}|%Quantity% > _|GoldValue={DSGet~Treasure,%Index%,GoldValue}|%GoldValue%{CR~} > _|Index+1|} > _._,_._,_ > ------------------------------------------------------------------------ ? ? ? ? ? |
Re: Arrays to track count?
In the :AddItem group you're using DSAdd, which returns the index of the entry added. You need to use DSAddNR which does not return any value.
toggle quoted message
Show quoted text
(I'd forgotten about that when I gave the example using DSAdd earlier.) Or you could get clever and replace {DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%} with |NumRecs={DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%}| which will save you from having to do |NumRecs={DSCount~Treasure}| in the :Display group. Erol K. Bayburt ErolB1@... On 4/6/2021 4:37 PM, Otaku Smurf wrote:
Ok, I am just working a small test before I toss in the really big random table.? When I run this, I get an output like: |
Re: Arrays to track count?
Ok, I am just working a small test before I toss in the really big random table.? When I run this, I get an output like:
1 2 Emerald 3 1500 Ruby 1 2500 The first 1 and 2 are the index values.?? How can I stop those from being displayed?? I cannot for the life of me figure out where I am "printing" the index numbers.? Here is my code: #Declare Data Set
%Treasure%, 1
?
#Declare Variables
%TreasureType%, 0
%Quantity%, 0
%GoldValue%, 0
%NumRecs%, 0
%Index%, 1
%SavedIndex%, 0
?
?
:Start
1, {DSCreate~Treasure,TreasureType,NONE,Quantity,0,GoldValue,0}
_{Loop~4,[Generate1]} [Display]
?
:Generate1
1,|TreasureType=Diamond||Quantity=1||GoldValue=5000| [AddItem]
2,|TreasureType=Ruby||Quantity=1||GoldValue=2500| [AddItem]
3,|TreasureType=Emerald||Quantity=1||GoldValue=500| [AddItem]
4,|TreasureType=Sapphire||Quantity=1||GoldValue=750| [AddItem]
5,|TreasureType=Topaz||Quantity=1||GoldValue=200| [AddItem]
?
:AddItem
1,|SavedIndex={DSFind~Treasure,0,TreasureType=%TreasureType%}|
_{If~%SavedIndex%<0?
_{DSAdd~Treasure,TreasureType,%TreasureType%,Quantity,%Quantity%,GoldValue,%GoldValue%}/
_{DSSet~Treasure,%SavedIndex%,Quantity,{Calc~{DSGet~Treasure,%SavedIndex%,Quantity}+%Quantity%}}
_{DSSet~Treasure,%SavedIndex%,GoldValue,{Calc~{DSGet~Treasure,%SavedIndex%,GoldValue}+%GoldValue%}}}
?
:Display
1, |Index=1||NumRecs={DSCount~Treasure}|
_{Loop~%NumRecs%,
_|TreasureType={DSGet~Treasure,%Index%,TreasureType}|%TreasureType%?
_|Quantity={DSGet~Treasure,%Index%,Quantity}|%Quantity%?
_|GoldValue={DSGet~Treasure,%Index%,GoldValue}|%GoldValue%{CR~}
_|Index+1|} |
Re: Arrays to track count?
Erol, Perfect.? I think I can wrap my head around that.?? On Tue, Mar 30, 2021 at 11:09 AM ErolB1 via <ErolB1=[email protected]> wrote: I've only done a little bit with DS functions myself, but per the help |
Re: Arrays to track count?
I've only done a little bit with DS functions myself, but per the help file you need to include the default values in DSCreate
toggle quoted message
Show quoted text
{DSCreate~Gems,GemID,xxxx,Count,1} which sets up an empty array/temp table. Then when you spit out a new gem, you put it in a variable, e.g. NewGemID Then you use {DSFind~Gems,1,GemID=%NewGemID%} to find the index of that gem type if it exists, (-1 if it doesn't) If it doesn't exist, use {DSAdd~Gems,GemID,%NewGemID%} to add the gem (with the Count being 1 because we set it as the default). If it does exist, use {DSGet~Gems,%SavedIndexValueFound%,Count} to get the count, increment it by 1, and use {DSSet~Gems,%SavedIndexValueFound%,Count,%NewCountValue%} to save it again. So {DSSet~Gems,%SavedIndexValueFound%,Count,{Calc~{DSGet~Gems, %SavedIndexValueFound%,Count}+1}} to lump the last in a nested function. Erol K. Bayburt ErolB1@... On 3/30/2021 9:05 AM, Otaku Smurf wrote:
I am working on my own random gem table combining the 1ed DMG and articles from Dragon Magazine. |
Re: Arrays to track count?
That's definitely a way to do it. I know I've done exactly that in one of my tables way back when (for treasure generation), but I wasn't able to find it with a quick look. There might be an example in the Files section of the group. If I recall, the way I did it was to store the results in a dataset, and when each item was generated, I'd scan the dataset to see if it was already there. If so, I just incremented the count by one. If not, I created a new record with a count of one. ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, March 30, 2021 9:05 AM, Otaku Smurf <otakusmurfgaming@...> wrote:
|
Arrays to track count?
I am working on my own random gem table combining the 1ed DMG and articles from Dragon Magazine. I am able to loop through my initial?table, but that is spitting out one gem at a time.? Arrays have never been my strong suit in programming, and that has me at a disadvantage here. What I would like to do is when table generates: diamond, diamond, ruby, emerald, ruby to use the array to store and track the count of the results. so when I list out the results I can display 2x diamonds, 2x rubies, 1x emerald. Is this possible?? I was thinking?of something like this {DSCreate~Gems, GemID, Count}?? If I were in my SQL environment, I would just create a temp table and store each individual entry, then query for the counts.?? Thanks. |
Re: A tilda (~) before group/table calls?
Huh, I always assumed those were unintentional in most examples.
toggle quoted message
Show quoted text
~ is also used in the tiddlywiki format to prevent interpreting CamelCase as a wiki link On Fri, 19 Feb 2021 at 03:43, <scott@...> wrote:
|
Re: trouble with lnested IF statements
Found it! (I tend to post and then keep searching.. hehhehehe), it took me a few minutes to realize that I needed the =1 after the And function to get it to resolve as true.
My function now looks like :Holiday
1,{iif~{And~%monthName%=Ceathmi,%day%=1}=1 ? |holiday=New Year's Day|:?
_{iif~{And~%monthName%=Ceathmi,%day%=21}=1 ?|holiday=Ostara (Spring Equinox)|:
_{iif~{And~%monthName%=Asemi,%day%=5}=1?|holiday=Beltane|:
_{iif~{And~%monthName%=Sechtmi,%day%=21}=1?|holiday=Litha (Summer Solstice)|:
_{iif~{And~%monthName%=Anaomi,%day%=5}=1?|holiday=Lunasa|:
_{iif~{And~%monthName%=Adeimi,%day%=21}=1?|holiday=Mabon (Autumnal Equinox)|:
_{iif~{And~%monthName%=Dodhemi,%day%=4}=1?|holiday=Sowain Eve|:
_{iif~{And~%monthName%=Dodhemi,%day%=5}=1?|holiday=Sowain Day|:
_{iif~{And~%monthName%=Hamoi,%day%=21}=1?|holiday=Yule (Winter Solstice)|:
_{iif~{And~%monthName%=Atrimi,%day%=5}=1 ?|holiday=Imbolc|:|holiday=|
_}}}}}}}}}} |
Re: trouble with lnested IF statements
Logical operators in "if" (or "iif") statements isn't supported, but there are logical functions for And, Or, and Xor. So you could write your example something like: ? ?{If~{And~%monthName%=Ceathmi,%day%=1}=1?|holiday=New Year's Day| / |holiday=|} You could also put the If in the variable assignment to tighten things up a little: ? ?|holiday={If~{And~%monthName%=Ceathmi,%day%=1}=1?New Year's Day}| ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, February 25, 2021 10:26 AM, <tim@...> wrote:
|
trouble with lnested IF statements
Ok, so I am working on Calendar that also displays the weather. My output looks like this image -- note that I cycle through the entire month and display it all at once, each day one after the other.
What I am trying to do now is to get it to display the holiday information. The moon information was relatively easy, since I only had to deal with a single nested IF (i.e. checking the value of the %day% variable). But for the Holidays, I need to check both the month and day. My code works fine as long as there does not need to be a second holiday in a month. If there is, it never displays the second holiday. Note that I am calling the "Holiday" function/sub-table each time I build the contents of a given day (all my months have 30 days, so I basically loop 30 times, incrementing the day at the end before the next iteration) I figure that my call to Holiday is the issue, so I could use some Advice.... :Holiday
1,{iif~%monthName%=Ceathmi?{iif~%day%=1?|holiday=New Year's Day|:|holiday=|}:
_{iif~%monthName%=Ceathmi?{iif~%day%=21?|holiday=Ostara (Spring Equinox)|:|holiday=|}:
_{iif~%monthName%=Asemi?{iif~%day%=5?|holiday=Beltane|:|holiday=|}:
_{iif~%monthName%=Sechtmi?{iif~%day%=21?|holiday=Litha (Summer Solstice)|:|holiday=|}:
_{iif~%monthName%=Anaomi?{iif~%day%=5?|holiday=Lunasa|:|holiday=|}:
_{iif~%monthName%=Adeimi?{iif~%day%=21?|holiday=Mabon (Autumnal Equinox)|:|holiday=|}:
_{iif~%monthName%=Dodhemi?{iif~%day%=4?|holiday=Sowain Eve|:|holiday=|}:
_{iif~%monthName%=Dodhemi?{iif~%day%=5?|holiday=Sowain Day|:|holiday=|}:
_{iif~%monthName%=Hamoi?{iif~%day%=21?|holiday=Yule (Winter Solstice)|:|holiday=|}:
_{iif~%monthName%=Atrimi?{iif~%day%=5?|holiday=Imbolc|:|holiday=|}:
_}}}}}}}}}} (I really wish I could do something like {iif~%monthName%=Ceathmi && %day%=1 ? |holiday=New Year's Day| : |holiday=|} but I dn't think tablesmith support that, does it? Anyways, any help would be appreciated!! |
Re: Rolling until total reached
开云体育Or you could simply use {Loop~10, [roll]<br>} ? Sent from for Windows 10 ? From: tim@...
Sent: Friday, February 19, 2021 6:51 AM To: [email protected] Subject: Re: [TableSmith] Rolling until total reached ? First thing, you do not need? "?/ End" in every If statement. That might be blowing it up. :Start 1,Test Loop<br> _{While~%count%<=10, _%count%<br> _|count+1| _} ? |
Re: Rolling until total reached
开云体育The problem is with your |Total=%Total%+1| When you use = it is a Literal value and puts “0+1” as the value. What you want is |Total+1| or |Total={Calc~%Total%+1}| ? Vance ? Sent from for Windows 10 ? From: jimmyflowers1 via groups.io
Sent: Friday, February 19, 2021 3:59 AM To: [email protected] Subject: [TableSmith] Rolling until total reached ? I'm trying to create a table that keeps a running total of points to spend. Once it reaches the max, it stops producing results. # # _Test Table # ? %Total%,0 ? :Start 1,[Roll] ? :Roll 1,Rolled 1 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 2,Rolled 2 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 3,Rolled 3 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 4,Rolled 4 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 5,Rolled 5 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 6,Rolled 6 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 7,Rolled 7 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 8,Rolled 8 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 9,Rolled 9 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> 10,Rolled 10 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> ? |
Re: Rolling until total reached
First thing, you do not need? "?/ End" in every If statement. That might be blowing it up.
You also don't need???|Total=%Total%+1| in every line, |Total+1| is all you need there. However, a simpler solution would be to look at a While loop.... %count%,0 :Start
1,Test Loop<br>
_{While~%count%<=10,
_%count%<br>
_|count+1|
_} In this loop, you call it and it prints out the following: Test Loop 0 1 2 3 4 5 6 7 8 9 10 |
Rolling until total reached
I'm trying to create a table that keeps a running total of points to spend. Once it reaches the max, it stops producing results.
Here is the structure I attempted with dummy text. When I run, the program exits (crashes). Any ideas? #
# _Test Table
#
?
%Total%,0
?
:Start
1,[Roll]
?
:Roll
1,Rolled 1 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
2,Rolled 2 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
3,Rolled 3 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
4,Rolled 4 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
5,Rolled 5 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
6,Rolled 6 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
7,Rolled 7 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
8,Rolled 8 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
9,Rolled 9 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br>
10,Rolled 10 |Total=%Total%+1|{If~%Total% != 10 ? [Roll] / End}<br> Some of the text in the table appears merely for testing purposes. The rolls will actually all lead to separate groups/tables so that ultimately I end up with 10 blocks of text from various other tables. Any help is appreciated. Thanks in advance. |
Re: A tilda (~) before group/table calls?
开云体育It allows for a reroll of the item from the interface. It will be colored blue to note its availability. ? Scott ? From: [email protected] <[email protected]> On Behalf Of tim@...
Sent: Thursday, February 18, 2021 19:08 To: [email protected] Subject: [TableSmith] A tilda (~) before group/table calls? ? In several examples in the help file, there is a ~ (a tilda) before the table/group call, like this
Anybody know what the sinifigance is? |
A tilda (~) before group/table calls?
In several examples in the help file, there is a ~ (a tilda) before the table/group call, like this
Anybody know what the sinifigance is? |