Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - decletro

Pages: 1 2 3 ... 15
1
Ask a Question / Re: Saving with Code
« on: February 06, 2013, 09:25:20 am »
Sorry for the late reply - had exams etc so haven't been checking these forums.

You should just be able to use arrays like any other data type when saving - it works for me.

If you're just looking to save every game attribute without having the delay that comes with Stencyl's in-built saving (when played online), then you can use this saving code:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes)
{
    sharedObject.data[key] = (getGameAttribute(key));
}

And the loading code is:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes) {
    if (sharedObject.data[key] == null) {
        if (typeof(getGameAttribute(key)) == "String" ||
            typeof(getGameAttribute(key)) == "Number") {
           
            setGameAttribute(key, 0);
        } else if (typeof(getGameAttribute(key)) == "Boolean") {
            setGameAttribute(key, false);
        } else if (typeof(getGameAttribute(key)) == "Array") {
            setGameAttribute(key, new Array());
        }
    } else {
        if (typeof(getGameAttribute(key)) == "string") {
            setGameAttribute(key, String(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "number") {
            setGameAttribute(key, Number(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "boolean") {
            setGameAttribute(key, Boolean(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "array") {
            setGameAttribute(key, Array(sharedObject.data[key]));
        }
    }
}

I tried this method and the arrays still wont work as expected. Seems that they are emptied after closing the game and loading it again.

Have you tried making a new game and using the code, just to make sure that it isn't a different part of your game that's messing with the arrays? Arrays are definitely working for me.

EDIT: Just remembered - are you setting the list defaults? Whether you use my saving system or the in-built one, Stencyl does not save the default inputs to a list when done using the in-built method. You need to create a behaviour to manually input all of the default values to your GA lists.

2
Ask a Question / Re: Saving with Code
« on: February 06, 2013, 09:23:29 am »
I have a question about your final solution (and updated to the first post) if I copy that code into a custom code block for my save sections of the game will what is written there save every game attribute I want or specific ones? I would love to get rid of that 1 second lag every time it autosaves in my game.

Also if I use the saving code listed in this post will the prebuilt load block work or will I need to use the load code too?

And finally, why wouldnt this be pre-programmed into stencyl 2.x ? Whats the benefit/drawback to using this code?

You can copy and paste the code into a global code block and then you have a new 'save' block to use instead of the in-built one. Or if you're only going to save once in your code, just put the code block in there.

If you have multiple games, change the 'gameSaves' String to something more unique to the game like 'SpaceShooterSaves' or something otherwise they'll all overwrite each other.

But yeah, the code saves (and loads) every game attribute. If you want to save just specific ones, you'll need to use the code from further back in the thread; the 'final' code uses the same idea but just looks through every game attribute so you don't have to manually input them all.

Stencyl's in-built saving block uses the 'flush' command which sends all of the currently saved info to the save file on your PC - this is what causes the delay. However, the 'flush' command happens automatically when the game is closed so it's unnecessary to do it every time. I don't know why the Stencyl developers don't remove the flush command - maybe they are unaware of the delay (since there is no delay when played locally).

I don't know of any other disadvantages. Both of my games made with the above code have had no saving bugs reported to me:
http://www.stencyl.com/game/play/15239
http://www.stencyl.com/game/play/17006

Hypnohustla says the code doesn't save arrays properly for him but it works for me. Might be other parts of his code causing the problem for him. I suggest you just try it out.

3
Ask a Question / Re: Saving with Code
« on: January 26, 2013, 05:09:36 am »
You should just be able to use arrays like any other data type when saving - it works for me.

If you're just looking to save every game attribute without having the delay that comes with Stencyl's in-built saving (when played online), then you can use this saving code:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes)
{
    sharedObject.data[key] = (getGameAttribute(key));
}

And the loading code is:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes) {
    if (sharedObject.data[key] == null) {
        if (typeof(getGameAttribute(key)) == "String" ||
            typeof(getGameAttribute(key)) == "Number") {
           
            setGameAttribute(key, 0);
        } else if (typeof(getGameAttribute(key)) == "Boolean") {
            setGameAttribute(key, false);
        } else if (typeof(getGameAttribute(key)) == "Array") {
            setGameAttribute(key, new Array());
        }
    } else {
        if (typeof(getGameAttribute(key)) == "string") {
            setGameAttribute(key, String(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "number") {
            setGameAttribute(key, Number(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "boolean") {
            setGameAttribute(key, Boolean(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "array") {
            setGameAttribute(key, Array(sharedObject.data[key]));
        }
    }
}

4
Ask a Question / Re: Massive 'Open URL' Problems
« on: October 26, 2012, 09:43:41 am »
To get around the pop-up blocker problem you have to use a click event listener.  See here: http://community.stencyl.com/index.php/topic,13578.msg80186.html

Thank you!!! That fixed it!

5
Ask a Question / Re: Adding Mochi Ads
« on: October 25, 2012, 04:16:26 pm »
I never did solve this - ultimately I just used Mochi preloader ads and used the sponsor's SWF as a splash screen as soon as it started.

6
Ask a Question / Massive 'Open URL' Problems
« on: October 25, 2012, 04:11:30 pm »
Okay so I've been working all day today trying to solve this problem because my game was meant to be released today. The problem is so simple but Stencyl just doesn't seem to be able to do it.

I want to be able to open a URL in a new window. Or a new tab. Or even in the same tab. That's it. I've spent 10+ hours today trying to accomplish this and feel like an idiot when my sponsor doesn't understand what the problem is... Here's what I've tried:

1) 'Open URL in browser' block - this is blocked by pop-up blockers
2)
Code: [Select]
navigateToURL(new URLRequest(_url), "_self"); code - this is meant to open the URL in the same tab, but it actually makes the button do absolutely nothing when played on an actual website (it works on the SWF but not on Stencyl.com)
3)
Code: [Select]
navigateToURL(new URLRequest(_url), "_blank"); code - this is meant to open the URL in another tab, but again is blocked by pop-up blockers
4) I've tried all kinds of crazy solutions from Google, none of which worked.

Can anybody please help me out here? It's so awkward because I've already been paid for this and now we can't launch the game because of the most ridiculous little problem at the end...

7
Ask a Question / How to get a splash screen to play
« on: October 24, 2012, 10:19:12 am »
Hey - my sponsor has given me a SWF to play at the start of the game. Right now, I'm using the 'Custom Loading SWF' setting to play it, but the problem with this is that if the game loads too quickly, the animation is not played.

Is there a way to force the game to show the custom loading screen swf for a minimum amount of time, or just to play the swf at the start of the game?

8
Ask a Question / Re: Adding Mochi Ads
« on: October 24, 2012, 09:32:39 am »
bump

9
Ask a Question / Adding Mochi Ads
« on: October 23, 2012, 01:31:59 pm »
Hey, Mochi Ads just don't seem to work for me.

I have:

1) Signed up to Mochi ads, submitted my game and got a game ID, which I placed into the 'game settings' settings in the box 'Mochi Game ID'.

2) I did the global settings thing to allow it to work locally.

3) In design mode, I have placed the code block to add a mochi add in various places but when I publish and test the game, it just doesn't come up. The same thing happens when I try this with the game actually on the Mochi server.

4) The game gets rejected by Mochi for not having ads in it.

Anyone have any ideas? I actually think I'd prefer to add click-away ads though...

10
Ask a Question / Re: Saving with Code
« on: October 23, 2012, 01:29:36 pm »
Stencyl is doing the same thing anyway. It use SharedObjects and flush() for the Save block.

You can make some objects to move on the screen and attach the flush() to a key. I think it will have a little lag.

The best way to use the flush() is when the scenes are in transition or something like that.

Actually, there is no delay at all now. The flush() is what seems to cause the delay, but because the swf automatically does flush() when you close it anyway, reprogramming the saving system using SharedObjects but not including calls to flush() seems the best way to:

1) Choose which game attributes to save
2) Get rid of the 1+ second delay every time you save

11
Ask a Question / Re: Saving with Code
« on: October 23, 2012, 11:37:52 am »
Okay so I managed it - here's how if anybody's wondering:

Where you would normally save, use the code (for example):

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameNameSaves");
sharedObject.data.blahblah = (getGameAttribute("blahblah")as Number);
sharedObject.data.blahblah2 = (getGameAttribute("blahblah2")as Boolean);
...

Then to load:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameNameSaves");
if (sharedObject.data.blahblah == null) {
setGameAttribute("blahblah", 0);
} else {
setGameAttribute("blahblah", Number(sharedObject.data.blahblah));
}
if (sharedObject.data.blahblah2 = null) {
setGameAttribute("blahblah2", false);
} else {
setGameAttribute("blahblah2", asBoolean(sharedObject.data.blahblah2));
}
...

You can use the line

Code: [Select]
sharedObject.flush();
to save data right away, but I reckon that's what probably causes the delay - it always flushes when the game is closed anyway. Right now, I'm sure the above code saves correctly, but I haven't tested yet whether this fixes the delay problem - I'll edit this when I test it soon.

12
Ask a Question / Saving with Code
« on: October 23, 2012, 10:46:03 am »
Hey - is it possible to save only some game attributes using code?

The saving blocks are incredibly slow - there's a very noticeable delay that is over 1 second long on slower machines, even for a small number of game attributes. I actually only need to save about 5 game attributes for a particular game despite having tens of them, and so I'm wondering if I could write a bit of code to save these certain attributes in the traditional way that somebody would if using Flash.

EDIT WITH FINAL SOLUTION:

Turns out the problem is that Stencyl uses the 'flush' command with its in-built saving, which works fine when played locally but causes a delay when played online. The solution is the following code:

SAVING:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes)
{
    sharedObject.data[key] = (getGameAttribute(key));
}


LOADING:

Code: [Select]
var sharedObject:SharedObject;
sharedObject = SharedObject.getLocal("gameSaves");
for(var key:String in Game.get().gameAttributes) {
    if (sharedObject.data[key] == null) {
        if (typeof(getGameAttribute(key)) == "String" ||
            typeof(getGameAttribute(key)) == "Number") {
           
            setGameAttribute(key, 0);
        } else if (typeof(getGameAttribute(key)) == "Boolean") {
            setGameAttribute(key, false);
        } else if (typeof(getGameAttribute(key)) == "Array") {
            setGameAttribute(key, new Array());
        }
    } else {
        if (typeof(getGameAttribute(key)) == "string") {
            setGameAttribute(key, String(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "number") {
            setGameAttribute(key, Number(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "boolean") {
            setGameAttribute(key, Boolean(sharedObject.data[key]));
        } else if (typeof(getGameAttribute(key)) == "array") {
            setGameAttribute(key, Array(sharedObject.data[key]));
        }
    }
}

13
Ask a Question / Re: Saving is Slowwwwwwwwww
« on: October 05, 2012, 09:57:23 am »
If I wanted to save my randomly generated dungeon, so the user can come back to the same point in his adventure, the dungeonmasterlist game attribute which is a list has 220*220*5 (242,000)entries, at the moment the lists for monster stats, container contents, player stats and player inventory do not exist. when it's more built will have to put it somewhere I can test the delay, I suspect it will be horrible, a quick test locally showed it can save the main list instantly, so I wonder of the delay is directly proportional to the amount of data or not. Can anyone verify?

Edit: /of course saving the entire dungeon mid game after pushing a button to do so, is a far more understandable delay than freezing when entering a level, so I'm not sure if this is going to bite me in the bottom later or not. Time will tell I suppose.

Probably best to do a quick test - make a new game with a behaviour that automatically fills a game attribute list with however many entries you're expecting, then test it. Remember, the delay only occurs online so test it on Stencyl.com, then remember the delay will be several times longer on other websites. Honestly, it seems any type of saving at all will cause a delay though so saving at the start of each level just isn't viable no matter how much data you have.

14
Ask a Question / Re: Saving is Slowwwwwwwwww
« on: October 04, 2012, 01:20:20 pm »
Just for my own curiosity: how many game attributes do you have in your game? You can also make your own saving system and you can save just some game attributes and not all of them.

One game had maybe 30 or so, the other had less than 10.

15
Ask a Question / Re: Saving is Slowwwwwwwwww
« on: October 04, 2012, 12:19:13 pm »
Its Miner, on my profile. But, actually, now that I'm looking at it, it does pause for a brief moment when it saves.

I'll have to see if 3.0 still has this problem. In the mean-time, you'll have to work around it by finding a time to save when nothing is happening (or perhaps throw up a "saving" box so the user knows what's happening).

And another thing to note is that that brief moment is much less on Stencyl than on other sites (notably flashgamelicense) because (and I don't know the technical details), most game portals can't use the 'wmode' paramater to the Flash control which I think Stencyl probably does, and this makes the game run slower and so in turn makes the saving take longer.

Also, on worse computers, the delay is much larger - a sponsor told me that my game delayed for over 2 seconds per level!

And for many types of games, there just is no work-around other than having a save button that the player has to explicitly press. It's better to just remove saving completely than to have 'saving' come up for like half a second - it'd annoy players way too much.

Pages: 1 2 3 ... 15