5E Character Create Playlist
Page 1 of 2 12 Last
  1. #1
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29

    Creating, Cloning, or Writing a Class for dragdata

    Has anyone had any success with creating a dragdata object from scratch?

    I need one inside a double-click event handler. Some controls in the character sheet have both drag and click functionality, that pretty much end with the same result. It appears as though much of my work would be done if I could populate a dragdata object inside the click handler and send it on its way.

    But I have not found any way to create a blank or empty dragdata object. LilCthulhu asked this same question back in 2010, and Moon Wizard sent him to throwDice(). I started going down that rabbit hole and it's scary down there.

    I also tried draginfo.createBaseData("dragdata"). This seems to be a "cloner". You need an original to clone from, and there is no persistence. When the original dies, the clone dies (becomes empty or non functional).

    So, two questions:
    (1) After eight years (LilCthulhu's question) can we still not instantiate a fresh dragdata object?
    (2) If I write my own class (lua table) with embedded functions and variables that mocks the dragdata object, your opinions on how successful it might be when I send it into the maze of onDragStart/onDrag but originating in onDoubleClick?

    Thanks, in advance for your help, opinions, chides and gaffaws .
    Current Projects:
    Always...
    Community Contributions:
    Extensions: Bardic Inspiration, Druid Wild Shapes, Local Dice Tower, Library Field Filters
    Tutorial Blog Series: "A Neophyte Tackles (coding) the FG Extension".

  2. #2
    This is from my DOR Deadlands Classic Ruleset and deals with a "Fate Chip" construct that gets Dragged and Dropped to and from a number of locations.

    Code:
    		oDragData.createBaseData("fatechip");
    		oDragData.setType("fatechip");
    		oDragData.setIcon("iPokerChip" .. sChip);
    		oDragData.setDescription(sChip);
    		oDragData.setNumberData(1);
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  3. #3
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Thank you dulux-oz.
    Interesting. I suspect this rectifies the persistence problem I had. But isn’t oDragData in the code above a dragdata object itself? Meaning I have to have one to create one? Otherwise, if I understand correctly, it would not have the embedded createBaseData() function.

  4. #4
    You can not create a dragdata object from scratch. The createBaseData API creates a child dragdata object, but requires a dragdata object to create.

    Regards,
    JPG

  5. #5
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by Moon Wizard View Post
    You can not create a dragdata object from scratch. The createBaseData API creates a child dragdata object, but requires a dragdata object to create.
    Waaaah! That's kinda of what I thought. Thanks Moon Wizard.

  6. #6
    Quote Originally Posted by Minty23185Fresh View Post
    Waaaah! That's kinda of what I thought. Thanks Moon Wizard.
    Is it possible to trick the system by code to think that an instance of dragdata was created, so that information from it may be processed?
    FG License: Unity Ultimate License
    Timezone: -5 EST/EDT

  7. #7
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by MyGivinOpinion View Post
    Is it possible to trick the system by code to think that an instance of dragdata was created, so that information from it may be processed?
    It is much more complicated than that.
    The dragdata “table” is very much like a class in other languages. It has get and set functions embedded. So code down the line does a
    draginfo.setDescription(blah);
    rather than a simple
    draginfo.desc = blah;
    I wil have to add all those property getters and setters to my pseudo-dragdata “object”.

    I tried what you suggest, create a dragdata table put in my data, and sent it on its way. It didn’t make it very far before an error was thrown complaining of such-and-such “get” function was nil.
    Last edited by Minty23185Fresh; March 7th, 2019 at 15:20.

  8. #8
    Varsuuk's Avatar
    Join Date
    Dec 2015
    Location
    New York
    Posts
    2,075
    Riiiight... the “duck” principle.

    Since the “typing” in Lua is quite coarse, and tables are their “classes”, you could in theory actually recreate a DragInfo class/instance if you implemented it completely, maybe? I’m too ignorant. However as an opaque object it is u likely you’d get enough of it done and done right, in effect Lua would just give you enough rope to shoot yourself in the foot with

    If I needed it, Id quickly copy and

  9. #9
    Minty23185Fresh's Avatar
    Join Date
    Dec 2015
    Location
    Goldstone, CA, USA
    Posts
    1,211
    Blog Entries
    29
    Quote Originally Posted by Varsuuk View Post
    ... shoot yourself in the foot ...
    Agreed. I alluded to this in my (unanswered) second question, in the original post.

    Quote Originally Posted by Varsuuk View Post
    If I needed it, Id quickly copy and
    I think I know where you were headed with this. If I’ve guessed correctly, I also mentioned copying (or cloning) an original and lack of persistence.

    Thanks for the input.

    I like a good challenge and plan on giving this a go here in the near future. Working on DWSI at the moment though.

  10. #10
    Quote Originally Posted by Minty23185Fresh View Post
    Agreed. I alluded to this in my (unanswered) second question, in the original post.


    I think I know where you were headed with this. If I’ve guessed correctly, I also mentioned copying (or cloning) an original and lack of persistence.

    Thanks for the input.

    I like a good challenge and plan on giving this a go here in the near future. Working on DWSI at the moment though.
    Please let me know how it goes, I'm currently trying to do something similar with drag data. i'm trying to access it while still performing an onhover
    FG License: Unity Ultimate License
    Timezone: -5 EST/EDT

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
  •  
FG Spreadshirt Swag

Log in

Log in