-
November 13th, 2018, 00:06 #11
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
-
November 13th, 2018, 00:09 #12
Also? Didn't these forums use to have a code-tag?
-
November 13th, 2018, 00:27 #13
-
November 13th, 2018, 00:32 #14
-
November 15th, 2018, 22:31 #15
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,538
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
-
November 16th, 2018, 01:32 #16
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
-
November 16th, 2018, 09:14 #17
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,538
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
-
November 16th, 2018, 18:37 #18
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.
- ObeLast edited by Oberoten; November 16th, 2018 at 20:56. Reason: Missed important parts of my answers, added an image.
-
November 16th, 2018, 21:00 #19
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
-
November 17th, 2018, 00:17 #20
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,538
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