PDA

View Full Version : Inventory Drag and Drop from Module 'CoreRPG'



Ardem
February 4th, 2017, 06:03
I notice that since the change to inventory, not sure which Core version. My drag and drop from Module has stopped working.

I also notice that when you copy from one character sheet to another it moves the said gear instead of duplicate. Which is nice but also a pain, as sometimes I use this to duplicate regular gear (NM: Found a way, you move the name not the shortcut). Also a pain is unable to duplicate gear to the same character (just add to the total). I want to add 3 potions, that have different names I used to drag and drop great a duplicate and modify it slightly.


My question is what changes are made around which lua and xmls. I had version 3.1.4 and loaded that up and the old way works so I know it was after this. My main goal is to get my drag and drop working from module file of equipment.


My record_char_inventory.xml is pretty much the same as default Core, it is a merge join with a couple of extra fields about weight


A cut down verison of my module looks like this




<reference static="true">
<equipment>
<waterbottle>
<type type="string">Goods and Services</type>
<subtype type="string">Adventuring Gear</subtype>
<name type="string">Water Bottle</name>
<cost type="string">US$ 20</cost>
<weight type="number">.1</weight>
<description type="formattedtext">
<p>Theses 1 litre water bottles made out of stainless steel to keep water clean. A full bottle weighs 1.1 kgs</p>
</description>
</waterbottle>
</equipment>
</reference>
<lists static="true">
<equipment>
<section002>
<description type="string">Adventuring Gear</description>
<equipment>
<waterbottle>
<link type="windowreference">
<class>referenceequipment</class>
<recordname>reference.equipment.waterbottle@Extinction Event Basic Rules</recordname>
</link>
<name type="string">Water Bottle</name>
<cost type="string">US$ 20</cost>
<weight type="number">.1</weight>
</waterbottle>
</equipment>
</section002>
</equipment>
</lists>

damned
February 4th, 2017, 12:34
I thought inventory management changed pretty much how you described it so that it worked "properly" eg items dont double up they adjust number, you give someone the sword from your gear you dont dupe it to them...

I know thats not your actual Q/A but I think the changes were deliberate.

You can use Party Sheet to do what you want I think.

Ardem
February 4th, 2017, 16:22
Thanks Damned, still not been able to figure out why it is not accepting from my module though. Will try again tomorrow.

Ardem
February 5th, 2017, 04:46
Moon this is driving me around the bend, I would request include two things with Core, atleast so you are able to test things work in basic Core, because this is a pain in the arse, just to test drag and drop of inventory, or module stuff.

You should include a basic Module, which has some basic equipment and some basic reference equipment xmls. This would help other community developers starting out as well, in how to develop rulesets, the biggest draw back in starting to develop anything in Core is that there is no base level rulesets you need to rip apart the complex ones to understand how even the basic things are done. Anyway RANT switch off <wink>

I am struggling to find where the issue is, I have used the Core lua files of item.lua, item_main.lua, camp_invent.xml and still the drag and drop is not working for it. I cannot understand why a simple drag drop from a module does not work. *Insert swear word here*

I know it has to be due to the switch when data_library.lua came onboard but I am bpass this code with old code and still cannot find the little bugger that stopping it.

Ardem
February 5th, 2017, 05:04
I am starting to think its not me but the a Core Ruleset issue, I just downloaded Shadowrun 4 community ruleset and tried the drag drop ability it also does not work. Is there any community rulesets that work on inventory drag and drop items from module, as I would like to look at your module code to see what the issue is.

Moon Wizard
February 5th, 2017, 05:55
The link for the object must be "item" for the drag and drop to work. If it is item, then a copy of the record is created when added to PC inventory or the campaign items list. Whether the record contains the right data is irrelevant, it's the drag "type" that triggers the actions. If the actual data fields are wrong, then they just won't show up when you look at the item detail record.

If you're still having problems, can you post a sample module with a couple items?

Regards,
JPG

Ardem
February 6th, 2017, 00:49
Moon please review the cut down module code above what field am I missing?

Should I substitute <equipment> with <item>,

or should I be looking at the ref_equipment.xml (own made reference for displaying data from library) around this, I am really at a loss, where I should be looking to make sure it is an item. As I said if the top part of post, 99% of the inventory tab is the same and what is not the same is an addition in the weight area separate from the drag drop code. I need a hint in where I should be looking for the fault.

Moon Wizard
February 6th, 2017, 20:01
"referenceequipment" is not a valid type in CoreRPG, only in 3.5E/PFRPG. So, this link needs to be changed to have a class of "item", and then the link should be accepted by the PC sheet and the campaign list.

JPG

ianmward
February 8th, 2017, 01:07
"referenceequipment" is not a valid type in CoreRPG, only in 3.5E/PFRPG. So, this link needs to be changed to have a class of "item", and then the link should be accepted by the PC sheet and the campaign list.

JPG

Or you can implement ItemManager2 with an isItemClass() that identifies the class "referenceequipment" as an item class, right?

Ardem
February 8th, 2017, 01:33
Moon: Changing the class to item worked, thanks for that, however a further question about this

1/ what are the available options 'armor, weapon etc??' that can be posted in the inventory window?

I tried 'armor', however this did not seem to work, also 'weapon' and this also seemed to not work. Only when the class was 'item' works. I would like these included in the inventory window, as it helps with the weight. I am assuming i am need to do some code change but what script is this area located now, it was manager_item.



Ian: Well that is how I had it working in the past i had this code below, now it does not work.





function isItemClass(sClass)
return StringManager.contains({"referencearmor", "referenceweapon", "referenceequipment"}, sClass);
end

function addItemToList2(sClass, nodeSource, nodeTarget)
if isItemClass(sClass) then
DB.copyNode(nodeSource, nodeTarget);
DB.setValue(nodeTarget, "isidentified", "number", 1);
return true;
end

return false;
end

Ardem
February 8th, 2017, 02:51
So this is the new code, but it makes my head hurt. The code above I could understand this one is a little out of my league

This is based on this code 'Debug.console('DEPRECATED (v3.2.2) (ItemManager.isItemClass): Use LibraryData.isRecordDisplayClass("item", sClass)');'


function isRecordDisplayClass(sRecordType, sClass)
if aRecords[sRecordType] then
if aRecords[sRecordType].fIsRecordDisplayClass then
return aRecords[sRecordType].fIsRecordDisplayClass(sClass);
elseif aRecords[sRecordType].aRecordDisplayClasses then
return StringManager.contains(aRecords[sRecordType].aRecordDisplayClasses, sClass);
elseif aRecords[sRecordType].sRecordDisplayClass then
return (aRecords[sRecordType].sRecordDisplayClass == sClass);
else
return (sRecordType == sClass);
end
end
return false;
end

If someone can psuedo code the above code it might help me figure this out. Sorry I know I never said i was a coder but I try my best.

This code is in the rec_char_inventory.xml I think this is where I need to include armor and weapons but not sure how

local bID = LibraryData.getIDState("item", getDatabaseNode(), true);

Moon Wizard
February 8th, 2017, 04:14
Are you trying to build a new ruleset on top of CoreRPG, or are you just trying to make a CoreRPG item library?

If you are building a new ruleset, you should be looking at scripts/data_library_35E.lua in the 3.5E ruleset (or similar in the other official rulesets) for how additional item types are added. (And look for instances of those new item types in the ruleset also.)

If you are just trying to make a CoreRPG library, then you will have to use "item", and there is no concept of different item types. Otherwise, you need to build an extension or ruleset.

Cheers,
JPG

ianmward
February 8th, 2017, 05:22
Ninjaed!

Ardem
February 8th, 2017, 09:33
Trying to fix up the Extinction Event ruleset once it broke in 3.2.2 due to the new code, which but will review data_library_35E to fix it thanks

Moon Wizard
February 8th, 2017, 17:50
Yeah, definitely review the data_library_35E script. From the item class names used, I think you will be able to borrow heavily from the 3.5E/PFRPG implementation.

Cheers,
JPG

Ardem
February 14th, 2017, 08:03
So to tie this off all nicely and thanks to ianward for the additional support. the final code need included a new data_library_EE.lua. to use with the existing item_manager2 code. This all worked great!


function isItemRecordDisplayClass(sClass)
if sClass == "item" then
return true;
end
return ItemManager2.isItemClass(sClass);
end

aRecords = {
-- CoreRPG override
["item"] = {
bExport = true,
bID = true,
sIDOption = "MIID",
aDataMap = { "item", "reference.items","referenceweapon","reference.weapon","referencearmor","reference.armor" },
aDisplayIcon = { "button_items", "button_items_down" },
sListDisplayClass = "masterindexitem_id",
fIsRecordDisplayClass = isItemRecordDisplayClass,
},
...