PDA

View Full Version : Allowing usage of customdie in effect



Zwikkel
April 14th, 2021, 16:09
Hi,

I have added a custom die "d5" via an extension. It can be selected via rightclick->customdie in the standard "d10" and works as it should there.

Now I want to be able to use this custom die in an effect like "HEAL: 1d5" so that whenever a healing action/roll is done an additional d5 is rolled and added to the result.
However I can not find a starting point where to do this.

Can anyone give me a hint where I should be looking at?

Best regards,

LordEntrails
April 16th, 2021, 05:29
MOD: moved to Workshop from CoreRPG forum. I think you will get better visibility here and since you are really talking about extensions and coding, this is an appropriate place.

Zwikkel
April 16th, 2021, 12:22
Thanks for the guiding.
I will also take the chance to elaborate a bit more on what I already have and what I want to achieve.

So I have created an extension with the following code:

<icon name="d5" file="graphics/radial/icon_dice_d5.png" />
<customdie name="d5">
<model>d10</model>
<menuicon>d5</menuicon>
<script>
function onValue(result)
local msg = {sender = "", font = "emotefont"};
msg.text = "Rolled " .. result .. " on d10! Converting to d5 via division by 2.";
Comm.deliverChatMessage(msg);
return math.ceil(result/2);
end
</script>
</customdie>

Now I have the new d5 and can select and roll it via the custom dice in the standard d10 selection.
That way I can also add it into a dice field of an action(e.g. a heal action). This works fine and the correct d5 is rolled once the heal action is triggered.
Now I also want to be able to add the new d5 as a modifier via an effect. E.g. in an effect "more heal; HEAL: 1d5". The intention is that whenever a heal action is performed by someone who is having this effect an additional 1d5 is rolled and added to the heal amount.
Though this is not working. I can only add the standard dice in the effect like d6, d8 and so on. But not my newly generated d5.

I also had a look around in the CoreRPG.pak ruleset but I could not find any place where I need to register my d5 so that it will work as I want.
Hopefully someone can give me a hint how I can solve this problem.

Moon Wizard
April 16th, 2021, 16:22
As far as I know, CoreRPG doesn't support adding any dice by effect. In CoreRPG, the effects are only informational (except for upcoming LIGHT/VISION effects).

In other rulesets, the code that adds dice via effects uses the StringManager.convertStringToDice function to convert the effect string to dice; and that function uses Interface.getDice API to grab the possible dice. This is exactly how d2/d3 are implemented and used in 5E and Pathfinder.

Regards,
JPG

Zwikkel
April 17th, 2021, 09:53
That sounds good.
I'll have a look into these functions and see how I can add my changes with that.