[Retitled] Amalgam of vaguely related questions.

For questions about using Classic.

Post » Fri Apr 15, 2011 12:48 am

You shouldn't notice a performance impact with a 50x35 array and leaving entries blank. However, one way to do it would be to have a hashtable hold your characters with the value an index into the array. That way you would always get really quick access to your array info without any searching or sorting. When you delete a character, the hashtable entry would be deleted (the hashtable is an automatically sized list) and the index could go into a deleted index hashtable for use later if you add a character back.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Apr 15, 2011 1:04 am

I'd always prefer maintenance over speed. You never know how much issues you will get with too much wasted RAM or illogical code.
You shouldn't be too afraid of maintenance slowing your app down, though. I tested an array with 10000 cells, moving the contents of 9999 by one to the left. I could do this on every tick without touching the v-synced framerate of 60 fps. In your app you will never experience a situation, where you would constantly move 10000 cells per tick.
If you are interested, how actual events would look like (and behave), have a look at Verve!
The sorting algorithm featured there works simultaneously on 4 arrays, moving the contens of cells, deleting entries, inserting data, etc.

If you can find a way of identifying your objects with keys, then you could use a hash table and place all data as a tokenized string for the values of the keys. It would cost you another routine to pack and extract the data from the strings, but you would never have gaps in your hash table, no matter how often you delete or add something.

You could also setup your own array structures (like arrays storing other arrays or sub-arrays) by using the 's'-plugin.

Python would also allow for custom classes. You could create something like:
[code:ep387qqo]class Profile(object):
def __init__(self):
self.name = None
self.age = None
self.height = None


class Group(object):
def __init__(self):
self.profiles = []

def create(self):
self.profiles.append(Profile())

def delete(self, index=None):
if index == None:
del self.profiles[-1]
else:
del self.profiles[index]

def set_age(self, index=None, age=0):
if index == None:
self.profiles[-1].age = age
else:
self.profiles[index].age = age

def get_age(self, index=None):
if index == None:
return self.profiles[-1].age
else:
return self.profiles[index][/code:ep387qqo]

You would then use it this way:
[code:ep387qqo]#Your array
ProfileArray = Group()

#Create a new profile
ProfileArray.Create()

#Set the age in the newly created profile to 18
ProfileArray.set_age(None, 18)[/code:ep387qqo]

Saving the data is as simple as using file.write() after having prepared the values. (Won't go into details here, but it really isn't much effort.)

You see, there are many ways, it is up to you to decide which way to go :)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Apr 16, 2011 9:05 pm

Again, I appreciate all the ideas. For now, I think I will go with the simple and brutish approach to get it up and running for my friend and I. As we'll be using it for some time, I do plan on refining it both visually and functionally, so it will likely go through some under-the-hood revisions (likely in the veins you've both suggested) to make it smoother and easier to handle.
B
2
G
1
Posts: 14
Reputation: 478

Post » Sun Apr 17, 2011 8:09 am

Edit: Using the debugger informs me that event 5 is attempting to add a string to an integer. Looking into it.

Edit 2: Solved the Integer/String conflict. Apparently only part of the problem. I'll look into it more tomorrow...for now, bed.

Edit 3: Fresh morning! Fresh mind! It appears to be working properly now. After fixing the Integer/String conflict, it ended up being a conditional fallacy in the blocks and a mistyped variable. I can now save new characters and it will properly seek out and overwrite existing characters with new information. Thank you for your patience!

Next up, the delete function. That should be delightful. :P

Also, the debugger in this is great. It's so clear in listing everything that you're looking at. No more archaic C++ debuggers. <3
B
2
G
1
Posts: 14
Reputation: 478

Post » Fri Apr 29, 2011 11:22 pm

Hello again!

After many days, things are looking good. The profiler is in a functional condition, although it still lacks things like failsafes against common user errors and has a few quirks left to iron out. Still, it does the most basic things that will allow us to start using it and storing character data. I'm having a friend put it through the ringer, since another pair of eyes always finds something I've overlooked.

One such case was brought to my attention. I'm using the Box Object to allow the display of a particular color, selected by the user. The color is set by means of the Windows Color Picker via the Common Dialog Object.

The problem is that if you cancel out of picking a color, instead of leaving the color in the Box in question alone, it will set it to the previously selected color.

Rather than include the entire profiler (which is still a mess and needs intense optimization and reworking in many areas), I have distilled the problem down to a tiny .CAP with just a few events. It allows accurate reproduction of the error. If anyone can figure this one out, I'd be much obliged. As it stands, a simple misclick could cause loss of your selected color, and that's no good.

CAP File:
http://largeangryrobot.webs.com/ColorBoxes.cap
B
2
G
1
Posts: 14
Reputation: 478

Post » Fri May 06, 2011 11:27 pm

I feel like I've committed some kind of sin for quadruple posting, but I still haven't figured out the color box matter.

I tried using the "On Colour Dialog OK" event condition, but it produces another strange result. Particularly that it has a full one event cycle delay before applying the color to the box. So, the first time you hit OK it applies a blackish color to the box, even if you selected red. If you repeat the action, it would apply red to the box, even if you picked orange.

With the help of the other posters, the search function, and the wiki, and some thoughtful workarounds most problems thusfar have been conquered. I just can't seem to trample the Colour Dialog problem, though. :[
B
2
G
1
Posts: 14
Reputation: 478

Post » Fri May 06, 2011 11:53 pm

I think whats happening is the color picker has to read from the gpu, so it will take a tick to get the color, so getting the color within the same event just wont work.
My solution, use a function.

[url:3w4txa5p]http://dl.dropbox.com/u/666516/colorpickerfix.cap[/url:3w4txa5p]
made in: Construct Classic r1
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271

Post » Sat May 07, 2011 6:34 am

Thank you very much, Newt. That has entirely solved both the "Cancel" problem and the single cycle delay when using the "OK" condition.

It has, however, created a different issue, wherein picking the color in the second box will also change the color in the first box. I can see exactly why. The condition of the Toggle private variable from the other is still true when the second box is also color picked, so it recolors both.

That one I can probably smash my head into until the solution clicks. It's always facepalmingly simple when I figure it out. Makes me feel like such a dunce sometimes. :P

Again, thank you for introducing me to the function there. It's got things on the right track! For now, it's late, so I'll putter with it tomorrow.
B
2
G
1
Posts: 14
Reputation: 478

Post » Wed May 11, 2011 1:59 pm

Well, the fix was indeed simple. I hadn't had the opportunity to work on it for a few days, but when I got to it this morning it took all of about five minutes to put it in. It could actually probably be trimmed down at this point, as I think it may have gotten slightly redundant. Ultimately, it works now, though. Everything else is gravy.

Here's the properly working color picker boxes for anyone interested. Thanks again to Newt, Tulamide, Tokinsom, Scidave, and Sully for help in this little endeavor. The solution in the colorpicker CAP can now be implemented into the profiler.

The profiler's not worth posting yet, but if it develops into a more generally useful tool, it may get posted in the future. :]

http://largeangryrobot.webs.com/colorpickerfix2.cap
Construct Classic r1
B
2
G
1
Posts: 14
Reputation: 478

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests