Cameron9990's Forum Posts

  • Everything is possible. You just need to pick that other instance of the same object or family. You can use "System Pick All":

    > On Card clicked
    Card compare variable code="A"
    ... Pick all Card
    ... Card compare variable code="B" : Card set variable price to 100
    

    or call a function:

    > On Card clicked
    Card compare variable code="A" : Call function UpdateAnotherCard(Code: "B")
    
    On Function UpdateAnotherCard
    .....
    
    

    I uhh... don't think I did it right. Keeps picking the wrong card.

  • Try adding "For each Cards" condition to that event.

    Also, why are you using UIDs as key names? UID is not a reliable identifier. If cards are created in runtime, their UIDs may be different every time the game or layout is restarted.

    If you are placing cards manually in the layout editor, their UIDs will stay the same until the card is destroyed. Still I suggest using an instance variable as a unique card ID.

    I did UID because that's what the other guy suggested. Also... is there literally any way to interact with other copies of the same object in a family? Like if I click on an object it'll change the variable of another of the same object?

  • Like I want it to where whenever you either left click one of the objects on the left, it deletes itself and lowers the variable of the one on the right, or whenever you right click the ones on the right, it lowers the variable of how many are in then deletes one of the ones on the left. Either one works, or preferably both.

  • > Exact same way I did it for Cards.GetObjectType only that one didn't need to start with str()

    The code on your screenshot works fine for me.

    Are you using "Set key" or "Add key" action? Use "Add key", because "Set key" only works if the key already exists.

    Well now that that's working, I'm trying to make a number variable equal to this, it there a way to recall it and turn it back into a number? Like on start of layout set "number" to dictionary.get(str(Cards.UID)) I just don't think it's converting to a number so it's staying 0 since str is in it, is there a way to fix that?

    If it's not that then I'm confused.

    The first one is changing the value, the second one isn't.

  • > Exact same way I did it for Cards.GetObjectType only that one didn't need to start with str()

    The code on your screenshot works fine for me.

    Are you using "Set key" or "Add key" action? Use "Add key", because "Set key" only works if the key already exists.

    I... I could of sworn I hit copy and paste and then tweaked the words... I'm not sure why it was "set key", you are absolutely correct. Thank you for the clarification.

  • I think we may be talking about different things at this point. I was talking about something along the lines of:

    Mykey = str(sprite.uid)

    Dictionary: add key mykey with value dictionary.get(mykey)+1

    But I may have misunderstood what was being asked.

    Exact same way I did it for Cards.GetObjectType only that one didn't need to start with str()

  • I don’t understand what you mean by str() doesn’t work with a dictionary. Sure it requires that the key be a string but you can convert a number into a string with the str() expression and it’s happy. And I’m not just saying that, I’ve done it a lot.

    Wait I'm confused, I did what you're saying, the value is just never increasing, no matter what I do, it says 0.

  • dop2000R0J0hound

    Sorry for only just responding, been busy with work. But uhhh... well the string thing doesn't work with dictionary, it always comes out as 0, it works with JSON but it's not saving. But I'm also not used to working with JSONs so I'm probably doing that wrong. But even just leaving the layout and coming back it's not doing anything, turns to 0 so uhhhhh... what do?

  • Consider using JSON instead, you can store any amount of data for each card. For example:

    > CardJSON set path to CardName
    CardJSON set ".quantity" to (CardJSON.get(".quantity")+1)
    CardJSON set ".price" to 500
    

    To retrieve a value: CardJSON.get(CardName & ".price")

    idk, I use Construct explicitly when I don't feel like coding, I don't think there was any other ways to do JSONs unless I'm just blind.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That sounds fine to have a value per type in the family. If you wanted a value per instance you could use cards.uid as the key.

    If you wanted multiple values per type or instance you could just use another dictionary or append something like “:value1” to the key or something. For example cards.uid&“:value1”

    Unfortunately UID is itself a number. The key for a dictionary can't be a number.

  • The only way I've been able to do is

    But I need at least one more way to do a number value. Anyone got anything?

  • Try removing "Is overlapping Deck" condition in the function. If it fixes the issue, then investigate why some cards may not be overlapping the deck. Or move this condition in front of the For Each loop.

    I moved it in front and it worked, thanks you guys.

  • dop2000 and igortyhon I uhh... may need an explination for what's going on with the spawning here...

  • All the cards keep stacking in the same spot instead of doing the loopindex bit.

    Tagged:

  • My text would go past the bottom of the layout so I want a way to just shrink the text box but make it to where you can scroll though text, is there a way to do that? Or like, to make it to where the bottom of the text box is always at like the bottom of the text? I think either would work.

    Tagged: