PDA

View Full Version : Double dice when dropping on portraits?



Moon Wizard
July 14th, 2008, 02:30
I have a routine that I am writing for my ruleset that allows you to drop an attack dice on a PC portrait. When you do that, I set up a call to throwDice with a custom data field (targetpc) that can be read from the onDiceLanded handler.

However, whenever I drag the attack dice (d20) to the portrait, the results of the die roll are fine (getDieList returns 1 die result), but FG shows 2 d20s rolling.

Any ideas on what is causing?

Thanks,
JPG

Moon Wizard
July 14th, 2008, 08:29
Update:

I changed the call from an automatic d20 in the throwDice function call, and made it use the dropped draginfo.getDieList() value.

Now, I see the correct number of dice roll. However, when I attempt to use the draginfo.getDieList() function in the onDiceLanded handler, I get a nil value returned.

Thanks,
JPG

Moon Wizard
July 14th, 2008, 08:56
Another update:

When reading the dragdata object in the onDrop handler of characterlist_entry, all the values appear to be fine except the one returned by getDieList().

For getDieList, I get {{}, ...} where the number of internal empty sets is equal to the number of dice I'm trying to roll. I used the # (count) operator and the type() function to determine this.

type dice = table
size dice = 1
type dice[1] = table
size dice[1] = 0

Thanks,
JPG

Moon Wizard
July 17th, 2008, 07:35
OK, another update on this one:

1. For some reason, ipairs() will not iterate completely over a list when it is built in certain ways. You have to use the pairs() function.

2. The dice table that is being returned by getDieList in the onDrop handler of characterlist-entry.lua is of the form {{"d6"}}, where the dice are doubly nested. If you pass the getDieList() value to the throwDice() function, it will get a nil value for the dice in onDiceLanded().

3. I tried rebuilding a new dice table, by iterating over the doubly-nested table, then passing the new dice table to throwDice(). Now it rolls the dice I want, but still displays double the number of dice thrown. I double-checked to make sure that I return true after processing the onDrop.

Any ideas on why getDieList() is returning the dice list in a different format than expected, or why I'm seeing double dice thrown?

Thanks,
JPG

Foen
July 17th, 2008, 19:12
Sorry I can't help on this one, but I have encountered it as well. Some of the tables returned by built in functions cannot be iterated using ipairs(), I think databaseNode.getChildren() is also one of them.

Stuart

Dachannien
July 17th, 2008, 23:17
As for the double dice, this is just a thought, but when you drop a die on an entry in the characterlist, you're actually dropping it on two objects: the characterlist and the characterlist_entry. Maybe if you put an onDrop event function in the characterlist and return the proper value (false? true? not sure) it will suppress the extra dice.

I'm probably wrong, but I didn't have this problem with The Box, which is an independent non-nested panel, and that's the only real difference I see.

Moon Wizard
July 19th, 2008, 02:58
Good idea. Unfortunately, it didn't change anything.

Cheers,
JPG

Moon Wizard
October 1st, 2008, 23:22
OK, a bit more information on this one, since I am revisiting it.

Now, I have 2 features that are showing double dice. Dropping rolls on CT entries and TheBox add-on.

In TheBox add-on, I enabled TheBox on the GM side. (to allow GMs to make hidden rolls even when reveal rolls is enabled)

Now, TheBox works fine for client rolls, but shows double dice on GM rolls. In the LUA script, the ChatManager.deliverMessage(msg, "") throws an error when called by the host. So, I changed the behavior of TheBox script for the host to just call ChatManager.processDie() instead, which is what happens for the client rolls anyway after the message is delivered and captured in the host onReceiveMessage(). However, I see double dice on the host rolls but not the client rolls.

I have tried returning different values in TheBox onDrop handler (true, false, nil) as well as draginfo.reset().

Any more ideas why I see double dice when calling ChatManager.throwDice() from another window or panel?

Thanks,
JPG