5E Product Walkthrough Playlist
Page 2 of 3 First 123 Last
  1. #11
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Quote Originally Posted by Moon Wizard View Post
    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


    Sorry for being on the slow side, this is what the field has so far... (I have gone over it over and over and have erased and commented out the parts that doesn't work)


    function onInit()

    end

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



    --addBitmapWidget("indicator_linked").setPosition("b ottomright", -5, -7);

    forms.setValue(temp3);
    castingtotal.setValue(temp1);
    --setLink(b);




    end
    end
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  2. #12
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Also? Didn't these forums use to have a code-tag?
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  3. #13

  4. #14
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Quote Originally Posted by damned View Post
    [ code] [ /code] without the spaces.
    I have been inactive for FAR too long it seems.

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




    Atque in perpetuum frater, Ave atque vale.

  5. #15
    Maybe you can post a work-in-progress so we can take a look at what you are doing? And also post an exact set of steps for how it should work?

    At this point, I don't have enough information to suggest a way to do what you are trying to do.

    Regards,
    JPG

  6. #16
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    What I have :

    I have a windowlist (spells) which contains a CastingTotal which is the sum of two numbers from a matrix. I have managed to get so I can drag the numbers and drop them onto the castingtotal so it is simple for players to cast their spells. But when the matrix is changed, it does not update the casting-total.

    What I aim for :

    Linking the fields so that casting total updates when the source updates.




    Current problem :
    Code:
    Runtime Notice: Reloading ruleset and data
    Script Error: [string "charsheet_spelllistitem:castingtotal"]:1: attempting to set a nil value as a handler function
    Script Error: [string "charsheet_spelllistitem:castingtotal"]:1: attempting to set a nil value as a handler function



    I have updated the numberfield "Castingtotal" to have the following in the script....


    Code:
    datanode = nil;
                    
                    function onInit()
                            datanode = window.windowlist.getDatabaseNode().createChild("castingtotal", "number");
                            datanode.onUpdate = update;
                            update();
                        end
                                    
                    function onDrop(x, y, draginfo)
                            local temp1
                            local temp2
                            local temp3
                            local temp4
                            local a,b
                              if draginfo.getType() == "art" then
                                temp1 = draginfo.getNumberData();
                                temp2 = draginfo.getDescription();
                                temp3 = draginfo.getStringData();
    
                                  if draginfo.getShortcutData() then
                                    a,b = draginfo.getShortcutData();
                                    datanode.setValue(b);
                                  end
                                
                                forms.setValue(temp3);
                                castingtotal.setValue(temp1);
                    
                              end
                    end
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  7. #17
    If I understand right, you don't want an update event on the castingtotal database node; since that's the field you want to be updated when other fields change, or when things are dropped on it.

    Some questions to help clarify, because I'm just not following what you're trying to do yet:

    * What game system are you trying to implement?
    * Is there a description of the game mechanic you are trying to recreate somewhere?
    * Please provide as much detail as you can, and at least a couple specific examples.

    * Do the numbers from the matrix change, or are they static?
    * Are there 2 distinct classes of numbers, such that when you drag a different number over that it should replace others?
    * Are there a small enough set of numbers that it would make more sense to provide a grid for them to click on to select the two items they want to apply?

    Regards,
    JPG

  8. #18
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Quote Originally Posted by Moon Wizard View Post
    If I understand right, you don't want an update event on the castingtotal database node; since that's the field you want to be updated when other fields change, or when things are dropped on it.

    Some questions to help clarify, because I'm just not following what you're trying to do yet:

    * What game system are you trying to implement?
    * Is there a description of the game mechanic you are trying to recreate somewhere?
    * Please provide as much detail as you can, and at least a couple specific examples.

    * Do the numbers from the matrix change, or are they static?
    * Are there 2 distinct classes of numbers, such that when you drag a different number over that it should replace others?
    * Are there a small enough set of numbers that it would make more sense to provide a grid for them to click on to select the two items they want to apply?

    Regards,
    JPG
    Game system is Ars Magica, based in the CoreRPG set.

    * Spells are cast in Ars Magica by combining a Stat (normaly Intelligence or Stamina) with a technique and a form value. Both of the later work as skills and can be raised in the course of the game. Examples of techniques are "Creo" (creation), "Perdo" (destruction), Intelligo (Percieve) combined with a form (What one wants to affect) So I have created a matrix of these.

    Spellmatrix.png


    There is a total of 50 arts, 5 Techniques x 10 Forms.


    When either Muto or Animal changes it allready updates the matrix : Giving per example the combination score of Muto (3) Animal (1) of 4.


    The spell-list then contains a spell-name, what combination it uses and finaly a casting total which is the getValue of the CombinedValues… What I need is to create a self-updating node that pulls the value of te combined form ciand technique. So if I pull the original value of say Muto Animal to the spell it should show Arts : "Muto Animal" (which it allready does) followed by the combined value in the casting-total.

    - Obe
    Last edited by Oberoten; November 16th, 2018 at 20:56. Reason: Missed important parts of my answers, added an image.
    For your Ars Magica needs :
    https://fgrepository.com




    Atque in perpetuum frater, Ave atque vale.

  9. #19
    Oberoten's Avatar
    Join Date
    May 2006
    Location
    Älvsbyn, Sweden
    Posts
    2,620
    Further explanation just because I can :

    The Arts are raised by adding Xp to the later number in each of the primary boxes. When enough is accumulated the Level raises and the matrix recalculates.

    Currently I can drag and replace a Matrix-number down tot he spell and it will populate the Forms and Casting values, but since the matrix is not static I need the Castingtotal (the value under Casting) to update automarticaly for each spell that shares the same attributes. IE All spells containing any of the Animal forms (and any Technique) should update whenever I raise Animal.

    .. the rest of the spell-field is fairly straightforward and works as intended. Lvl is compared to a roll triggered from the casting-total to see if a spell is cast sucessfully and if so at what cost.

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




    Atque in perpetuum frater, Ave atque vale.

  10. #20
    I would probably go about this a little differently.

    I would place all the code in the high-level window for updating the numbers. Then, in onInit event function, cycle through each spell, and write a function to set the casting total value based on the current technique/form value of the spell. Next, when a technique or form is dropped on a spell, then update the technique value, followed by using the same function to update the casting total based on the current technique/form of the spell. Finally, have each matrix cell control call a window.onMatrixChanged function in the windowclass whenever onValueChanged event fires for that matrix cell. In the onMatrixChanged function, cycle through all the spells again, and update the casting total value based on the current technique/form value of the spell.

    This is very similar to how the 5E skills tab works for updating skill totals based on attribute changes. (except attributes are no different tab, so I use database change handlers to capture attribute change events)

    Let me know if you have sample ruleset code you want me to look at.

    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