PDA

View Full Version : Passing "static text" in a roll string?



Varsuuk
December 31st, 2020, 09:20
Hey folks, I am new to messing about (changing) die strings.

I created one copied from THAC0 (well, underway, not done) but I'd like the roller to do some lookups and decisions based on stats, class, race and whether it is a melee or ranged attack. The first 3 are easy enough - the last I am not sure what to do.

Is there a way of passing this info as a bool (isMelee) or string "melee"/"ranged" or some other way as a parameter?
/mythac0 1d20+(b)x(a) is the base without the ranged/melee stuff.

Suggestions? I could, of course, create 2 different rollers but other than the mod decision tree there is no difference between them. I could encode the ranged/melee into the name of the roll like NAME (ranged) and search for that, but I dislike having people forced to name it a certain way.

Thanks ;) off to bed >4am

damned
December 31st, 2020, 14:15
You could extend that roll to something like:

/mythac0 1d20+(b)x(a)m|r

and use:

local sDice, sThac0, sType = sDicePattern:match("([^%s]+)x(%d+)(%a*)");

or similar...

Varsuuk
December 31st, 2020, 22:42
OOOOH... I get it.

I was thinking I had to do something with p1-3 or r1-3 etc. But I wasn't thinking straight - I can do as you said and add it to the end of the string manually. Will try that, thank you.

Varsuuk
January 1st, 2021, 01:01
Hey Damned, is there any full description of how to use this in a document or video? I tried the help web page which documents the rolls and how to add one to the xml files but not really this method:

function add_roll_type(name, perform_action, result_handler, use_modifiers, targeting, mod_handler, action_icon, total_handler)

name = roll_name
perform_action = the "performAction()" method that does the work/creates rolls.
result_handler = the "onLanded()" type action result handler you can define.
use_modifiers = whether to use/consume the current "modifier stack" value.
targeting = >> I passed "all", not sure what other choices exist.

The one I am interested in:
action_icon -> tried passing a MoreCore icon name "melee", I copied that icon to my icons, gave it a different name and passed it "eraseme_melee" then also tried passing explicit path: "graphics/icons/erase__button_melee.png" None of these seemed to create an icon to use as the roll button nor did it create an icon in the roll text itself.


I haven't looked at how "mod_handler" or "total_handler" works anywhere, if that is described somewhere it would rock too.



My original intent was to do "extra" work in the roller which is very specific to my ruleset and db fields. It would not be a "general" dice roll string. So I was trying to avoid doing the setup as per the web page instructions (which I did that way for the initial test as a total dupe of current taco then removed)

The rolling works (I suspect mod_handler and total_handler may be of good use to me - after reading/viewing docs or following the more core lua files) but the icon is not shown. ("Could not find icons [myrollname] for control [rollstype] in windowless [cli_rolls]" which is, of course, output each time I mouseover-past the place where the icon is to be displayed.

damned
January 1st, 2021, 01:41
Hi Varsuuk

It really is best to stick to the instructions. ianmward wrote the supporting code for that so that there was a clear way for other people to add new Rolls.

Copy an existing roll and update it to do what you want. There are way over a hundred rolls so there is going to be a solid base for most people to work from. You have the thac0 roll as your base - stick with that as it is already an opposed roll. Then follow the steps in the MoreCore User Guide https://www.diehard-gaming.com/mchelp.html#newrolls to hook it in.

You can leave the roll in your extension or when its ready send it to me with your permission to include it into the base. In that case dont call it mythac0 go with something like swthac0.

damned
January 1st, 2021, 02:10
OOOOH... I get it.

I was thinking I had to do something with p1-3 or r1-3 etc. But I wasn't thinking straight - I can do as you said and add it to the end of the string manually. Will try that, thank you.

Both ways are possible and both have some merit - you could do -

/mythac0 1d20+(b)x(a)y(p1)

and if p1 is 1 its melee, 2 its thrown and 3 its ranged

Why would you do this? mostly for weapons like Spear and Hand Axe where they can be used in more than one type of attack - the player could change it on the charsheet without having to open the roll - but they would also need to know what 1/2/3 were and that they were required.

Varsuuk
January 7th, 2021, 08:56
No this was for creating "rolls" for normal Items like "bow" or sling" which have ranged built into their morecore style string: "/swthac0 ranged|". When the modHandler (I read other code to find how to use the callbacks) is called, it can check if there is a +1 Dex bonus (all characters with the 13+ Dex ) and it can check for racial bonus (in this case, Halflings get +4 to all missile to-hits) without the user clicking things since the latter is not a "universal" bonus I can do it this way. It is more FUN than adding more and more DB fields to hold very specific bonuses - instead the modHandler can query the class/race for bonuses to type "ranged" for whatever reason.

If they create a roll for a ranged weapon and don't know to type ranged in it (because, for example, they didn't read the short "howTo packaged with the ext - then they can manually add +4 to the modifier stack each time - Freedom!