mardoch's Recent Forum Activity

  • Your first solution is working fine.

    The second one with the find expression looks great and more elegant but it seems there is an extra " somewhere…

  • Hello!

    I need to check if my object's variable contain one of the possible values.

    I know that I can use something like this:

    + System: Every tick
    + MapInOutCheck: MapInOutCheck = "upleft"
    ----+ MapInOutCheck: TypeChecked = "ULDR"
    ----+ OR MapInOutCheck: TypeChecked = "LDR"
    ----+ OR MapInOutCheck: TypeChecked = "UDR"
    ----+ OR MapInOutCheck: TypeChecked = "ULR"
    ----+ OR MapInOutCheck: TypeChecked = "DR"
    ----+ OR MapInOutCheck: TypeChecked = "UR"
    ----+ OR MapInOutCheck: TypeChecked = "LR"
    ----+ OR MapInOutCheck: TypeChecked = "R"
    ----+ OR MapInOutCheck: TypeChecked = ""
    -----> MapInOutCheck: Set Entrance to True
    

    But I was asking myself if there is a better and simple way to do it, like this for example:

    + System: Every tick
    + MapInOutCheck: MapInOutCheck = "upleft"
    + MapInOutCheck: TypeChecked = "ULDR"|"LDR"|"UDR"|"ULR"|"DR"|"UR"|"LR"|"R"|""
    -> MapInOutCheck: Set Entrance to True
    

    This isn't working, even if I read that "|" means "or"

    So maybe you guys have a solution for me?

  • Oh I see!! Alright!!! Now that's working!!!

    Thanks again for your precious help dop2000! You rock!!

  • Ok I get it, I just need to check the third line then.

    But the thing I still don't get is how do I tell my loop to only get the cells with my variable in it?

    This should work right?

  • Oops, sorry for the garbled code.

    Here is a clean version:

    + RestoreA: On clicked
    ----+ MyArray: For each XY element
    --------+ MyArray: Value at (MyArray.CurX, MyArray.CurY) = "TypeA"
    ---------> System: Create object MyArray.At(MyArray.CurX,1) on layer 0 at (0, 0), create hierarchy: False, template: ""
    
    --------+ System: Pick last created SpriteFam
    ---------> SpriteFam: Set from JSON string MyArray.CurValue
    

    I tried already using "For Each X" but i doesn't display anything at all.

    Why can't I use "XY" by the way? My variable is stocked on the second Y line, does it make sense to make it check there?

    Now I'm a bit lost…

  • So I add another data, an instance for each objects like TypeA, TypeB and TypeC.

    Everything is well saved in my array and all the new variables are saved on the new Y row. -> MyArray: Set value at (0, 2) to SpriteFam.Type

    My purpose now is to reload the objects by variable and I tried this:

    + RestoreA: On clicked ----+ MyArray: For each XY element --------+ MyArray: Value at (MyArray.CurX, MyArray.CurY) = "TypeA" ---------> System: Create object MyArray.At(MyArray.CurX,1) on layer 0 at (0, 0), create hierarchy: False, template: "" --------+ System: Pick last created SpriteFam ---------> SpriteFam: Set from JSON string MyArray.CurValue

    It almost worked. I have indeed the good objects with the correct variable but once again it change my object's positions and there is even one not positioned at all:

    Where is my mistake?

  • Alright, it works!!

    Thanks dop2000, I can finally move to my next issue!

    I suppose that if I want to save another data, for exemple an instance of the object, I need to do it in another Y row? (I still don't get when the Z in array is used)

  • Ok so i I get it right, beside of load state from JSON, I also need to save the object name and then use the create by name action (like "-> System: Create object "SpriteFam" on layer 0 at (0, 0), create hierarchy: False, template: """) ?

    I really am a rookie with the array so how can I add the sprite's name on it after -> MyArray: Insert SpriteFam.AsJSON at index 0 on X axis ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello everyone,

    I read a very efficient way to save each object's proprieties in with AsJSON on this topic:

    construct.net/en/forum/construct-3/how-do-i-8/save-sprite-properties-json-166321

    But why doesn't it works with families? I tried to reproduce the same code but on family's objects and even if it keep all informations (positions, angle, size, etc…), it display randomly every objects from the family.

    Here is the code I use
    And here is the messy result I get

    Is there a way to fix this?

  • Same for me. I just started to understand how arrays are actually working and I really need to get the logic about it.

    But I did get an important information: all objects has a AsJson expression.

    That's mean that everything about a sprite (size, position, actual frame, etc…) can be saves and load quite easely. Even variable I guess.

    It you create an event to save everything in your array like:

    + System: For each Sprite -> Array: Insert Sprite.AsJSON at index 0 on X axis

    Then if you want to call it back:

    + Array: For each X element -> System: Create object Sprite on layer 0 at (0, 0), create hierarchy: False, template: "" -> Sprite: Set from JSON string Array.CurValue

    Seems it works pretty well but I encountered a major problem: This is not working with families. It can't recognize sprites with their name and it mix everything when you call it back.

    And that's a big problem because I don't want to put this for every single sprite in my game (yep, I'm lazy XD).

    For now I have no solution.

    But even if I need to figure it out, I need to assign a new variable for each room that every single sprite in it can refer to.

    And I may have the solution for this with the mini map I'have created here:

    https://www.dropbox.com/s/yemjzks3vwv11xf/LevelGeneratorTest.c3p?dl=0

    For now it's not that bad even if I didn't really figure how to detect the entrances of the rooms already created, but I'm going on.

  • Ok I think I get it (a bit). I thought I could save every new room created in a JSON without using arrays. In the end there will be a lot of informations and variable for each, it could not be the easiest way to manage it.

    I also started to make a mini map. The interesting thing is that I can also probably save variables on it like "how many entrance there are in a room", etc… So when the player come back in it, the mini map could maybe ask the JSON all the stocked variables to "rebuild" the room?

  • Did you consider asking a studio to do this job? My team often ask to this studio to port our games and they do a pretty good job.

    Maybe you can ask them how much it could cost? Sometimes it’s more efficient and you save a lot of time…

mardoch's avatar

mardoch

Member since 21 Nov, 2013

None one is following mardoch yet!

Trophy Case

  • 12-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies