4th & Dragon : Dungeons and Dragons...and stuff

Hello there, stranger. Stay and sit a while.

You should Login or Register


   
 
I need some help from the Black Plauge…
Posted: 29 September 2008 01:00 PM   [ Ignore ]  
Rank
XP:   29
Level 1
Joined  2008-06-20

Hey, it’s me, Hirahito.

I’m having a problem with my MSE set where I show a combined field that has the Class, Type and Level all combined together.  I also have fields that have the Class, Type and Level all separate.  These fields aren’t shown on the card, so there’s no way for someone to edit them if they are entering in new cards.

Since I pre-load my MSE-SET using a flat file and a C# program, this isn’t a problem for ME… but it’s a huge problem for anyone trying to add in new cards.

Since I know Black Plauge is the guy that handles the MSE scripts, I was wondering if he could point me in the right direction on how to make my set auto-parse the combined field into the separate individual fields.

Any info would be appreciated…

-- Hirahito

Profile
 
 
Posted: 02 October 2008 08:09 AM   [ Ignore ]   [ # 1 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

You need to write a script or three.

Each script operates on the combined field, looking for some part of it, and then uses that to set the value for the other fields.

Example, you have a field called powertype which contains something to the effect of “Cleric Attack 1” and want to use that to fill fields called class, type, and level with the values “Cleric,” “Attack,” and “1” respectively.  The script then needs to differentiate the different parts of card.powertype.  There are two ways to do this:

1) You can use a series of if contains(string,match) statements.  This has the advantage of not caring about the exact order of entry or even whether all the elements are present.  The disadvantage is that you would need to be updated each time a new class or power type was added and you would have to check the list order for substrings, making sure that the more long string is matched before the string that it contains.  For example, the part of the script that fills the level field might look like this:

if contains(card.powertype,match:"30"then card.level 30
else if contains(card.powertype,match:"29"then card.level 29
else if contains(card.powertype,match:"28"then card.level 28
...

The reverse order serves to keep 30 from matching 3 (as to get to 3, we’ve already decided the string doesn’t contain 30).

2) You can use the break_text and regular expressions to break the string up into a list of substrings and then use that list to fill the fields.  The advantage is that this wouldn’t require updating.  The disadvantage is that field contents have to match the right format or the function won’t work.  For example, if the regular expression was keyed to break on spaces, then all classes and power types would have to be single words (which is the case so far).  For example:

break_text(card.powertype,match:"[^ ]+")

should break “Cleric Attack 1” into ["Cleric”,"Attack”,"1"]
I should note that I’m not real familiar with regular expressions, so I don’t know for sure how this would be implemented.  I’d have to play with it to get it just right.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
Posted: 02 October 2008 08:16 AM   [ Ignore ]   [ # 2 ]  
RankRankRankRankRank
XP:   224
Level 5
Joined  2008-06-18

Sorry to interrupt, but I have to nit pick this one little thing.

Black Plauge - 02 October 2008 08:09 AM

For example, if the regular expression was keyed to break on spaces, then all classes and power types would have to be single words (which is the case so far).

Wizard of the Spiral Tower Attack 11

Paragon paths shoot that assumption to pieces.  I’d recommend semi-colons.  Instead of “Cleric Attack 1” use “Cleric;Attack;1”.  “Wizard of the Spiral Tower Attack 11” becomes “Wizard of the Spiral Tower;Attack;11”.

Profile
 
 
Posted: 02 October 2008 08:52 AM   [ Ignore ]   [ # 3 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

Forgot about paragon paths.  Yeah, that throws the idea of breaking on spaces really out of whack.

Still, there is a problem with breaking on semicolons (or any other character) as then they’d show up in the combined field (which is what is actually on the card).

You might still be able to break on spaces, you’d just get a longer list in the case of classes that have spaces in the name: ["Wizard”,"of”,"the”,"Spiral”,"Tower”,"Attack”,"11"].  You’d then need to design your script to process this kind of unusual list and join some elements with spaces to make up some of the fields.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
Posted: 02 October 2008 09:19 AM   [ Ignore ]   [ # 4 ]  
Rank
XP:   29
Level 1
Joined  2008-06-20

Black Plauge -

First of all, thank you much for posting here.  I’m kinda new to the inner workings of the MSE, though I’m a programmer of 20+ years experience.

I’m quite familiar with Regular Expressions.  I’m of the strong opinion that, whenever I need a new regular expression written, I give my cat lots of catnip and dangle the catnip bag over the keyboard… within 5 minutes, an entirely new regular expr. ( or three) has been written.

But I also agree with Lakoda, the simple break on a string won’t work without some tweaking.  Since its essentially the same as a Split(” “), I could peel off the last two entries of the array (which would be the Attack/Utility and the level) and then reassemble the array with a Join(” “) which should give the string for the class.

Now… finding out how to do that in MSE is the problem…

Hmmmmm....

How about:

card field:
     
typetext
     name
name2
     description
Holds the 'Wizard of the Stiffie Utility 11' text.

card field:
     
typetext
     name
sub type
     description
Holds 'attack' 'utility' etc.
     
scriptbreak_list(inputcard.name2match"[^ ]+")[length(break_list(match"[^ ]+"))-2];   
     
#0 based

card field:
     
typetext
     name
level
     script
break_list(inputcard.name2match"[^ ]+")[length(break_list(match"[^ ]+"))-1];
     
#Last item?

card field:
     
typetext
     name
super type
     description
: Class or Race
     script
replace(inputcard.name2match"("+card.sub_type+"|"+card.level+")"replace"");
     
#Strip last two entries?

Is the best I can do at the moment (being at work).

What do you guys think?  Is this the right avenue to approach this?

-- Hirahito

Profile
 
 
Posted: 02 October 2008 09:36 AM   [ Ignore ]   [ # 5 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

The problem is that your going to run into problems with powers which don’t have a level (class features and racial powers mostly).  In this case your last entry is the power type, not the level.  You’ll probably need some sort of check that looks for this first.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
Posted: 02 October 2008 09:42 AM   [ Ignore ]   [ # 6 ]  
Rank
XP:   29
Level 1
Joined  2008-06-20
Black Plauge - 02 October 2008 09:36 AM

The problem is that your going to run into problems with powers which don’t have a level (class features and racial powers mostly).  In this case your last entry is the power type, not the level.  You’ll probably need some sort of check that looks for this first.

I looked at this to some degree.

Most of the non-level ones are things like ‘Drow Racial Feat’ which would make ‘Feat’ the level and ‘Racial’ the type.  Not sure if that’s OK or not (I’ll have to try it to make certain.)

Thanks for pointing that out though.

Any ideas on how to solve this better?  I know you’re better at this MSE scripting than I.

-- Hirahito

Profile
 
 
Posted: 02 October 2008 09:43 AM   [ Ignore ]   [ # 7 ]  
RankRankRankRankRank
XP:   224
Level 5
Joined  2008-06-18

When BP said semi-colons were out that’s pretty much what I was thinking.  Though I know nothing of MSE syntax, so I don’t follow exactly why semi-colons would show up, the regex should pull tokens out around the delineating character.  You know some important information about the last two fields; 2nd to last field is either ‘Attack’ or ‘Utility’, and the last is a number from 1 to 30.  If the code works use it!

edit - damn you beat me too it and I forgot about racial powers.  what about scanning for a number in the last character slot and having that drive which logic to use?  Again I don’t know if that’s even possible.  I’m leaving now, I really have no reason being here.  GL!

[ Edited: 02 October 2008 09:47 AM by Lakoda]
Profile
 
 
Posted: 02 October 2008 11:13 AM   [ Ignore ]   [ # 8 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

The problem is there are some which don’t have that final entry.  The power type for Fey Step is “Eladrin Racial”.  For Dragon Breath it’s “Dragonborn Racial”.  For Healing Word it’s “Cleric Feature”.  Plus, Feat isn’t a level, it’s more that the type is “Racial Feat”.

Checking for a number is probably the way to go.

Though I know nothing of MSE syntax, so I don’t follow exactly why semi-colons would show up,…

The reason for the semicolons showing up has nothing to do with MSE syntax.  It has to do with the fact that the field data is being entered into is a visible field on the card.  What you put in the box is what will show up on the card.  The three separate fields that we’re trying to fill based on this field are largely invisible.  They don’t show up on the card, but we’d like to have them filled properly so that they can be used in the card list and statistics as a way of sorting cards or analyzing the set.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
Posted: 02 October 2008 12:14 PM   [ Ignore ]   [ # 9 ]  
Rank
XP:   29
Level 1
Joined  2008-06-20
Black Plauge - 02 October 2008 11:13 AM

The problem is there are some which don’t have that final entry.  The power type for Fey Step is “Eladrin Racial”.  For Dragon Breath it’s “Dragonborn Racial”.  For Healing Word it’s “Cleric Feature”.  Plus, Feat isn’t a level, it’s more that the type is “Racial Feat”.

Checking for a number is probably the way to go.

How about the following then:

card field:
     
typetext
     name
name2
     description
Holds the 'Wizard of the Stiffie Utility 11' text.

card field:
     
typetext
     name
level
     script
{
                lvl 
:= break_list(inputcard.name2match"[^ ]+")[length(break_list(match"[^ ]+"))-1];
                if (
to_number(lvl) or else 0) = 0 then lvl := "";

                
lvl
             }
     
#Set to nothing if it's NaN

card field:
     
typetext
     name
sub type
     description
Holds 'attack' 'utility' etc.
     
script{
                last 
:= break_list(inputcard.name2match"[^ ]+")[length(break_list(match"[^ ]+"))-1];
                
nextlast := break_list(inputcard.name2match"[^ ]+")[length(break_list(match"[^ ]+"))-2];

                if 
card.level "" and to_upper(last) = "FEAT" then 
                    nextlast 
" " last;
                else if 
card.level "" then
                    last
;
                else
                    
nextlast;
            
}

card field
:
     
typetext
     name
super type
     description
: Class or Race
     script
replace(inputcard.name2match"("+card.sub_type+"|"+card.level+")"replace"");
     
#Strip last two entries?

Not sure if that will work or not, but the principle is…

If the last ‘word’ is a number, take it as the level, otherwise leave level blank.

if level is blank, make the ‘type’ the last word, unless the last word is ‘feat’, then take the last TWO words, otherwise make it the next to the last word.

The Class / Race is everything else.

-- Hirahito

[ Edited: 02 October 2008 12:18 PM by hirahito]
Profile
 
 
Posted: 02 October 2008 12:25 PM   [ Ignore ]   [ # 10 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

I agree with the principle of it.  You may have to play around with the code to make it actually work.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
Posted: 02 October 2008 12:29 PM   [ Ignore ]   [ # 11 ]  
Rank
XP:   29
Level 1
Joined  2008-06-20
Black Plauge - 02 October 2008 12:25 PM

I agree with the principle of it.  You may have to play around with the code to make it actually work.

Agreed.

Thanks very much for your help.  I’m having card users b**ch about not being able to put in new cards so I thought I’d fix it if I could.

-- Hirahito

Profile
 
 
Posted: 02 October 2008 01:08 PM   [ Ignore ]   [ # 12 ]  
RankRankRankRankRank
XP:   224
Level 5
Joined  2008-06-18
Black Plauge - 02 October 2008 11:13 AM

It has to do with the fact that the field data is being entered into is a visible field on the card.  What you put in the box is what will show up on the card.  The three separate fields that we’re trying to fill based on this field are largely invisible.  They don’t show up on the card, but we’d like to have them filled properly so that they can be used in the card list and statistics as a way of sorting cards or analyzing the set.

Duh, I wasn’t thinking.  Of course you’re just processing human readable entered data.  Thanks!

Profile
 
 
Posted: 02 October 2008 03:14 PM   [ Ignore ]   [ # 13 ]  
Rank
XP:   29
Level 1
Joined  2007-12-30

Is MSE Microsoft Service Enterprise?  I’d hate to think D&D 4.0 has become the same thing I have to look at all day at work!

Profile
 
 
Posted: 02 October 2008 04:00 PM   [ Ignore ]   [ # 14 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRankRank
XP:   1554
Moderator
Joined  2007-09-13

Magic Set Editor

M.JPG Winner June 2006 3EBB Character Creation Contest - Garick the Wise
d20Asigbanner2.gif

Profile
 
 
Posted: 03 October 2008 04:54 AM   [ Ignore ]   [ # 15 ]  
Avatar
RankRankRankRankRankRankRankRankRankRankRankRank
XP:   1071
Moderator
Joined  2007-09-13

If MSE was Microsoft Service Enterprise I wouldn’t touch it with a 10 ft pole.

Perhaps the only precept taught me by Grandfather Wills that I have honored all my adult life is that profanity and obscenity entitle people who don’t want unpleasant information to close their eyes and ears to you.

Donate rice by improving your vocabulary.

Because you don’t have anything better to do in January in Maine.

Profile
 
 
   
 
 
‹‹ Query      WorldWorks Games Paper Models ››
Powered by ExpressionEngine
ExpressionEngine Discussion Forum - Version 2.0.0 (20070724)
Script Executed in 0.4548 seconds
RSS 2.0     Atom Feed