Family's & Arrays, item sorting and selection(Solved W/CPAX)

Get help using Construct 2

Post » Fri Oct 10, 2014 9:01 pm

@nimos100 I really do appreciate you helping me but I really need someone to open the .CAPX to see if something is wrong on my end. The only plugin you would need is Rexrainbows CSVtoDictinary and all that I am trying to do is at the start of the layout add CSV's to five Dictionary's. Then when you right click run a foreachkey loop that is only looking for the value "T". Each Dictionary has 4 keys with values.

the exact keys are
"UNLOCK, T
A, 1
B, 2
C, 3"

With five dictionary's when I run a for each key loop I have a var add one for each key giving me a value of 20. But when I add a condition for only values with the string "T" I get 0 when I run the loop.

I honestly can not think of any simpler way to show what I am trying to do without someone looking at the .cpax
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Fri Oct 10, 2014 9:59 pm

You have a space after the comma so you're getting key: "UNLOCK", value: " T".
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Fri Oct 10, 2014 10:06 pm

CrazyVulcan wrote:I honestly can not think of any simpler way to show what I am trying to do without someone looking at the .cpax

Think you misunderstood me, I weren't referring to what was in the screenshot it self, more that it was so small that its difficult to read the code as some of it is really blurry.

But anyway I think Ramones solved it. :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Fri Oct 10, 2014 10:20 pm

@Ramones thank you so very much, to think it was something so small. I will work on the next part of my problem and report back on my progress later. In fact I may go back to arrays given that now I know where in the issue lies.

Thank you all for your help.
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Post » Tue Nov 04, 2014 2:22 am

Hello, I am just posting back here having finally solved the list of things I needed to figure out. And now it works exactly as I wanted :D I will write a tutorial when I get the spare time but for now this is a list of what I did to get this to work.

Image
To start here are the items you need to bring into the view port. A go button and blank avatar. A tileset with all your characters on it and one clone plus how many slots you plan to make. I made 3 so that is 4 clones of a tile set. A menu box, a tile for your avatars to sit on and highlight the stats of each. A CSV, found in the extensions from RexRainbow. And some text items to show your stats.

For the tile you will need to make it a container holding all the text items that go with each stat.
CODE===
//First we need to destroy the first tileset and the sprite backround for our tiles as the math we will be doing can be thrown if they are present after the layout is loaded.

On start of layout
Destroy Tileset
& Destroy Tile
& Load CSV Table form String}

CSV String
",Name,Unlock,Strength,Speed,Mana
0,Bob,T,0,0,0
1,Tim,T,0,0,0
2,Sue,T,0,0,0
//etc for each tile in your tile set. be sure that you list each character in sequence and tile 0 tile 1 and tile 2 will not only correspond to each image but will allow you to link that image to the CSV table for easy access to your stats.

//now we have the tile as a container for all out text items (also I have tied my tiles to the avatars so you can scroll through the list so know you can also do it the other way)
Every Tick
Tile - Set position to X: Tilemap.TileToPositionX(0) Y: Tilemap.TileToPositionY(0)
TextName - Set Position to Tile Image Point (1)
TextStrength- Set Position to Tile Image Point (2)
}
//you get it

Global Var's
Total - value of 0
TileSelect - value -1
ActiveSlot - value -1

Mouse LeftClick Slot0{
Set Var ActiveSlot to 0
Call Function "Menu1"}
//repeat for as many slots you will want

Function on "Menu1"{
Set background to position 500,100
>>>
CSV For Each Row
&
Compair CSV.At("Unlock",CSV.CurRow)="T"{
Add 1 to Total
Create Obj Tilemap on Layer(1) At X: Background.ImagePointX(0) Y: Background.ImagePointY(0)+(150*Total)-150
//This will add one to every run of the loop spacing out the placement of each avatar and tile
Set Tilemap - to int(CSV.CurRow)
Creat Obj - Tile on Layer(1) X: Tilemap.TileToPosition(0) Y: TileToPosition(0)+(150*Total)-150
TextName - Set Text CSV.At("Name", CSV.CurRow)
ValuStrength - Set Text to CSV.At("Strength", CSV.CurRow)
//and so on
Tile - Move to bottom of layer
Background Move to Bottom of layer}
}

Mouse - LeftClick on Tilemap
&
ActiveSlot = 1{

Set TileSelect to{ X: Tilemap.TileAt(Tilemap.PositionToTileX(Mouse.X)) Y: Tilemap.TileAt(Tilemap.PositionToTileY(Mouse.Y)}
//let me go over this one real quick. Tile select is a Var that is used to note which image I click on. So looking back at the CSV, and note that each row is numbered. So by clicking on Sue the var TileSelect will be set to 2 and later you will see that by having row 2 and Sue's image on the tile map the same this allows me to quickly know where my data is coming from.
Set Tileset to (TileSelect)
//then set the text items next to slot one to each stat
Set ActiveSlot to -1
Destroy Obj Tile
Set Total to 0
CallFunction "Destroy Tiles"

On Fun "DestroyTiles"
Destroy Obj Tilemap
Move Backround to -100,0
//this function is there because when I have it in the other block it will only destroy the tile that I selected. This allows me to get rid of all of them.

Repeat the last block for each slot that you have. This is all there is to it and I am happy that I managed to do this all with 13 blocks and 3 variables :D


.CAPX needs CSV by RexRainbow to open
You do not have the required permissions to view the files attached to this post.
"Were all mad here. I'm mad, your mad." "How do you know I'm mad?" Asked Alice. "You must be" Said the Cheshire Cat. "Or you wouldn't have come here"-Lewis Carroll: Adventures In Wonderland
B
7
S
2
Posts: 113
Reputation: 1,245

Previous

Return to How do I....?

Who is online

Users browsing this forum: batto, bclikesyou and 30 guests