Need advice on: Building a hierarchy tree

Get help using Construct 2

Post » Tue Mar 06, 2012 6:40 pm

Hi

I could use some advice.
I want to build a infinite hierarchy tree.
I can build the basics myself but there is one thing that is keeping me back from pursuing the build myself.

I'l explain.
The tree functions as follows:
The user puts a name in a textbox.
The name becomes a node on the branch of a tree.
The user puts in another name and selects a parrent node from a dropdown list, then a new branch is created(with the new node on top).
When the user has put al the nodes in he wants, he saves his progress and then exits the application.
On the next start of the program all last saved nodes are automaticly loaded.
The user then can continue building his hierarchy.

Now to the point.
I can figure out 90 procent of how to do this.
The one thing i cannot, is the save part.
I understand there is the webstorage plugin. (With its limits)
I also understand there is the ajax part of things. (needs knowledge on php and servers)
And i understand that construct 2 "at this point" does not have a save game state to server option. (Which if it would, just "saved" my day)

The point i need advice on is the question.
Is what i am trying to accomplish to difficult, for the stage of developement construct 2 is currently in?

A: If yes, then i would have a programmer i'm in contact with build this app for me.

B: If no, then i would really like to build it myself.
As building in construct 2 has become quite an adventure.




Thank u in advance for any advice.
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Tue Mar 06, 2012 7:01 pm

If you create the tree automatically, with math expressions (angle and etc), you just need the nodes info.

You can save each node indexed by UID's node.
The string saved would be parentUID-nodeLabel.

Iterating your tree example to the left, we have:

Key(0): -Concept Tree
Key(1): 0-JP
Key(2): 1- (don't have the euro symbol here)
Key(3): 1-WebApp
Key(4): 3-User
Key(5): 4-Creatie Meting
Key(6): 3-User
Key(7): 6-Creatie Meting

A key for qtyNodes is nice too, so you can loop using it as index.
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Tue Mar 06, 2012 7:18 pm

@Cassianno
Thanx for the fast reply.

2 questions.

1: What do u mean by: A key for (qtyNodes) is nice too, so you can (loop using it as index).

2: What save method do i use in your example: Webstorage or Ajax?

The tree should be created automaticly indeed.
B
56
S
20
G
13
Posts: 778
Reputation: 13,204

Post » Tue Mar 06, 2012 8:06 pm

Webstorage is like a cookie: you have a key and the stored value.

1)
In this example your webstorage would have 9 keys:
qtyNodes, storing the quantity of nodes you have on the tree and the nodes itselves (dunno if this word exists but u know what i mean), indexed from 0 to 7 (amount-1).

2)
It's up to you. I would go with webstorage because the setters/getters are easier to manage. Withing AJAX, you would have to make a request for every node and get its info...
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Tue Mar 06, 2012 8:09 pm

Oh, your question was about the loop part, rite?


To create the tree, you'll have a

>system Repeat WebStorage.Local("qtyNodes")
- index++;
- allocate the current (WebStorage.Local(index)) node within the tree {...}
English is not my native language. Sorry for any mistakes and feel free to correct me if needed.
B
14
S
5
G
3
Posts: 110
Reputation: 3,225

Post » Tue Mar 06, 2012 8:54 pm

Thank u for the advice!

I think i understand!
Il start building using your method and report back in the future
B
56
S
20
G
13
Posts: 778
Reputation: 13,204


Return to How do I....?

Who is online

Users browsing this forum: mercuryus and 15 guests