DICE PACKS BUNDLE
Page 1 of 3 123 Last
  1. #1
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620

    Red face Dragging and linking a field without making a link graphic on it...

    Hola.

    I have a matrix of values on my character-sheet that can be manipulated through other fields. (IE, each is a combination of two others), this in turn can be dragged to a windowlist below. Is there a good way to LINK the value in the windowlist so that when I drop per example the contents of "Creo Ignem" on a spell slot it should now hold a link to the node and update when it is changed?

    It feels like it should be obvious, I have seen it done on the combat tracker etc but can't seem to figure out the last step.

    - Obe
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  2. #2

  3. #3
    I think you’d need a more specific example to get an idea of what you want to do.

    For combat tracker, specific PC fields are synched between PC record and CT list item.

    Regards,
    JPG

  4. #4
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    On the combined numberfield i have so far tried this...

    function onDrag(button, x, y, draginfo)
    local a, b, c
    a = getValue();
    b = description[1];
    c = getName();

    draginfo.setShortcutData("charsheet_magic","CrAn") ;

    draginfo.setType("art");
    draginfo.setDescription(b);
    draginfo.setStringData(c);
    draginfo.setNumberData(a);
    return true;

    end



    The receiving numberfield inside a windowlist :

    function onDrop(x, y, draginfo)
    local temp1
    local temp2
    local temp3
    if draginfo.getType() == "art" then
    temp1 = draginfo.getNumberData();
    temp2 = draginfo.getDescription();
    temp3 = draginfo.getStringData();
    local a,b = draginfo.getShortcutData();
    print("Triggered Art " .. a .. " " ..b);

    forms.setValue(temp3);
    castingtotal.setValue(temp1);



    end

    if draginfo.getType() == "shortcut" then
    temp1 = draginfo.getNumberData();
    temp2 = draginfo.getDescription();
    temp3 = draginfo.getStringData();
    local a,b = draginfo.getShortcutData();
    print("Triggered shortcut " .. a .. " " ..b);

    forms.setValue(temp3);
    castingtotal.setValue(temp1);



    end



    end


    ... the idea is of course to make a link similar to how it is done on the Combat-tracker. So I have a casting-total for each spell directly on it's listing.

    -Obe
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  5. #5
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Quote Originally Posted by damned View Post
    would stringcyclers be another way to handle this?
    Possibly but it is a mix from 10 x 5 fields.Maybe if I did it with two cyclers instead.

    - Obe
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  6. #6
    You’ll want to use onDragStart; instead of onDrag. The former is called once; the latter is called every time the mouse is moved.

    For the capture; you won’t get any number/string data for the “shortcut” type; unless you have a custom drag function setting to shortcut plus extra data elsewhere.

    Are you getting the correct values returned by print function? You can also use Debug.chat function to keep from having to check console.

    Regards,
    JPG

  7. #7
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Replaced the onDrag with onDragStart.

    The line
    draginfo.setShortcutData("charsheet_magic","CrAn") ;

    passes over the class and the node name if understand correctly. But how do I turn this into a link so when I raise the CrAn score later the casting-score raises as well?

    How do I recieve the data beyond

    if draginfo.getType() == "art" then
    temp1 = draginfo.getNumberData();
    temp2 = draginfo.getDescription();
    temp3 = draginfo.getStringData();
    local a,b = draginfo.getShortcutData();
    print("Triggered shortcut " .. a .. " " ..b);

    forms.setValue(temp3);
    castingtotal.setValue(temp1);


    Which just gives it it's current value?

    - Obe
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  8. #8
    You would need to start retrieving database nodes based on the link passed; Store the node in a variable; set onUpdate and onDelete handlers for the node; and recalculate/remove based on the event.

    The number_linked template and script does something like that. It takes the values passed in the template control XML tags; saves off the nodes; and updates the total when they change.

    Regards,
    JPG

  9. #9
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Spent most of the day fiddling with this. ... it didn't go particularily well.

    function onDragStart(button, x, y, draginfo)
    local a, b, c, d
    a = getValue();
    b = description[1];
    c = getName();

    local node = getDatabaseNode();
    d = node.getPath();
    draginfo.setShortcutData("charsheet_magic",d);

    draginfo.setType("art");
    draginfo.setDescription(b);
    draginfo.setStringData(c);
    draginfo.setNumberData(a);
    draginfo.setCustomData(d);
    return true;

    end

    gives me charsheet ID node name.
    I can drop this to the recepient field (using a version of number_linked) which I fail to get to link to the node itself.

    - Obe
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  10. #10
    You are already setting the database node in setShortcutData(), so you don't need to add as custom data as well. Just pull out of draginfo.getShortcutData().

    This probably isn't the part that's not working as expected, as the dragging is the easy part. It's the handling of the drop, and subsequent linked behavior that will be the meat of the logic.

    Where's your code for the drop handling, as well as the handling for adding update events and updating when those events trigger?

    Regards,
    JPG

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in