How do I compare array data and reuse as a tooltip

0 favourites
  • 12 posts
From the Asset Store
DATA+ (Addon Pack)
$11.25 USD
50% off
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hey Dudes,

    need some help for dev a tooltip script equal to tooltips in games like diablo, poe or other rpgs.

    First some details.

    I store my Items in an array called "ainventory"

    Each Item data like affix, values, name (...) is stored in this array as "y", the index is "x"

    the item affix values like min. dmg or max. dmg is stored into its affix "y" as "z1", "z2", ...

    Now I want to show the items affix as a tooltip in a self adjusting textbox.

    So I created a function to:

    1. ask how many affix my item has (max_affix)

    2. loop at the correct "x", "y + curY", "z0-2"

    3. while looping append ainventory.curvalue into my textbox

    4. set textbox.height ---> textbox.facesize*max_affix

    pic-upload.de/view-26856468/tooltip.png.html

    So, it works very well but i can not determin the correct value how many affix my item has. It can have 3 but has only zero to 2 but i always get a max_affix result of 3. So my Textbox wont self adjust its size correctly, which means its size wont be zero if it isn't needed at all. If someone has an idea to fix my script i would be glad And sorry for my bad english =)

  • From what you described, your first bit of code should allow to determine the "max_affix" (what the hell is an "affix" ?).

    Unless you post your capx, I'm afraid no one will be able to help out and tell what is going wrong.

  • Thanks for ur quick reply - so, im going to figure out whats going wrong on my own unless my capx contains unique graphics im not allowed to share due to copyrights...

  • Well even though I can't see it your making it a bit complex when it could be simpler using just x and y you can hold you items like

    X0. X1. X2.

    Item name. Min_Damage. Max_Damage

    So Y0 which is technically row 0 will hold each piece of one item information across the x which is columns.

    Next if you are expanding and popping items as they come and go there is already a function that gives you the array size. Without having to do the first function. Then there is an event that will loop through each array for you already. So for what your trying to do it would loop through the y to compare. But that is all I can tell you with out having anything to see. You honestly don't need to use z index IMHO. Just note where everything is when you call them so if you just need to know min damage you know it would be in the x1 position. Basically every single thing about that item should be held in one row.

  • Hey,

    yeah i guess i did it the way u wrote. ...

    Each X represents its Itemslot in my Inventory. Each Y contains different informations for this item. Actually there are 27 different informations like name, icon, type, infotext, affix1, affix2, affix3 ...

    What I actually wanted to do is, for example, give my items some unique and non unique effects (Affix). For example, I have a sword which should have some kind of damage, attackspeed and probably mainstat. So, these informations are stored into an array at Y=Affix1, Affix2, Affix3 - to determine its range, for each Affix, i have to use "Z" because I will give the player the ability to change an items affix. This means Y=Affix1 can be, f.e., "Damage" but it could also be "Attackspeed" or "Melee Range" or even nothing at all. BUT - this is not the problem. The issue I have is, I wanna show the player an items affix within only one textbox and only want to use one tooltip for each item. This means, my tooltip script and its visual content should update and adjust itself on its own.

    Another Example:

    1. There is a Sword - my Mousecourse is overlapping this sword - my tooltip appears - it shows name, type, damage, affixes and some text.

    2. Then I drag my cursor over another item which is a "Key"

    3. So now I wanna use the same script for my tooltip which figures out: "Oh hell yeah, there are no affixes on this item, just name and type.

    4. Now, my scripts should look up Y=Affix1, Y=Affix2 (...) and recognize: "Ok really, all is "0", I dont need to append its content"

    5. This finally should end up in scaling up and down my tooltips content from zero to a perfect fitting size and automatically "exclude" all unnecessary information I do not need.

    So, finally, the problem is - u see my screenshot and my code - I ask for each possible affix: " ainventory.at( X=InventorySlot, Y=AffixLocation0-2, Z=0) NOT EQUAL 0 ". If it isn't Zero, I add 1 to a variable which should sum up the total affixes the item has. But always I get a total of 3 affixes my script sums up even if my comparison IS EQUAL 0, he adds 1 to my variable. And I use this variable to determine my textbox height. 0 Affixes should end up textbox.facesize*Variable=0...

    Here is a screenshot of my non scripted tooltip: directupload.net/file/d/3973/aituctbr_png.htm

    Here one of a screenshot while playing: directupload.net/file/d/3973/gh954gda_png.htm

    You can see, there is Attack, Attackspeed, 3, 4, 5, ... , but u should only see Attack, Attackspeed...

    ----

    Ok, you are right, its really confusing not having the code and reading this stuff but hope never dies i guess

  • For the affix why not store that in an instance variable versus an array??

    Actually...a lot of it you can store in an instance variable.

    Then with the tooltip it look at what object its over and look at the object instance variable to display the information.

    But if I can work up something later will show you

  • Sure this is a possible way I used in other projects but seems to take double time in work to get the same result for visuals. IF my idea would work, it would be a very lightweight piece of code in comparsion to use instance variables, adress each and ask each instance variable which kind of content it has aslong as I do not know how to loop through instance variables. Even an instance variable can only have one information while an array gives the possibility to store more than one information while using "Z" properly.

    So this is what I got so far:

    directupload.net/file/d/3973/yoxf2zjh_png.htm

    Here u can see the problem:

    directupload.net/file/d/3973/5tz9ne9n_png.htm

    The Textbox should adjust its size according to its content but I can't get this working properly ^^ Everything else works fine.

  • When you update a text object the width and height values won't be updated right away. You have to wait a few ticks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Waiting one tick is enough.

  • It's not a problem updating fast or slow its size... As I call a function to handle the tooltip behaviour and nothing else is working in the background things should update just in time.

    But, for now, it works. I solved the problem! I added the max amount of affixes into my array as a pre-given information, stored this into a local variable and reused this in a multiplication to determine my tooltips size...

    Pics:

    Zero-Information

    directupload.net/file/d/3973/as8m2b9v_png.htm

    One Information

    directupload.net/file/d/3973/ulqupdb4_png.htm

    Two Informations

    directupload.net/file/d/3973/nnyzlhjg_png.htm

    So my Tooltip will adjust its size depending on its content. Looks ugly but this will be improved later

    Thanks to all!

  • It's not a problem updating fast or slow its size... As I call a function to handle the tooltip behaviour and nothing else is working in the background things should update just in time.

    Yeah but the thing is you are checking win_tooltip_taffix.TextHeight immediately after setting the text but the TextHeight value doesn't update until the next tick. So you are checking the old height value before it has updated.

  • Ok now i understand - so, it would work if i set my text in function1 and set its size in function2? Firing another function would represent a tick i guess... !?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)