'S' update as of 4/12/11

New releases and general discussions.

Post » Mon Oct 19, 2009 3:19 am


(sweet. Kudos.)
Posts: 1,445
Reputation: 4,665

Post » Thu Oct 22, 2009 5:53 am

I need to spend more time with this plugin, so I can use families and containers together.
Posts: 1,763
Reputation: 18,822

Post » Thu Oct 22, 2009 5:15 pm

I have a small problem, I try to recreate your example but keeps crashing. Do you see any reason why it crashes when I pickup bullet2?
Posts: 100
Reputation: 4,840

Post » Thu Oct 22, 2009 5:57 pm

hey everyone
thanks for the patience.
the next tutorial should be here by the middle of next week. i hadnt intended it to take so long. but as i make these tutorials i discover features it should have and add them.

anywho, julmust, it is completely possible that i just put the wrong string there, but it looks like youre adding the object to an objecttype array. there is a separate action to add an object or a type
Spriter Dev
Posts: 3,235
Reputation: 16,326

Post » Mon Oct 26, 2009 4:15 am

coming soon:
the next tutorial will explain how to make a drag and drop level editor, that saves and loads encrypted level files, in just 4 events:
Spriter Dev
Posts: 3,235
Reputation: 16,326

Post » Mon Oct 26, 2009 6:47 am

Keep up this pace, lucid, fucking awesome! :)
Posts: 520
Reputation: 2,690

Post » Tue Oct 27, 2009 11:33 am

[quote="lucid":gzga72sn]coming soon:
the next tutorial will explain how to make a drag and drop level editor, that saves and loads encrypted level files, in just 4 events:

I was think of a way to using you plugin for that purpose.
I guess you beat me to the punch. :mrgreen:
Posts: 280
Reputation: 2,934

Post » Wed Oct 28, 2009 12:11 am

ok, here it is folks.
the long awaited SUPER tutorial

but first, let's go over some of the changes that have been implemented since our last visit.
first of all, the arrangement of the actions in the table has been changed. This is to consolidate it, hopefully place more important items closer to the top, but more importantly to keep you from having to scroll down as much. The side effect of this is that caps made with old versions of the plugin no longer work. Until I have time to remake the other tutorials I will have the new version as a separate download, so people can still do those tutorials. Also I've tried to hunt down all the "" instead of {""} default values in the fields that ask for an array. please let me know if you find any I missed.

Next is with object deletion. Now when you delete an object from an array, it will automatically delete all other instances of that object in the same array, and you have the option of replacing those elements with references to the default (with "as type" options), or deleting those elements from the array. this is the fix to the crashable problems before related to destroying an object and still having other copies of that object in the array.

Also, you can now delete an array. The action was there before, but didn't do anything, as it had not been implemented yet.

I don't have time to dig through all the old tutorials right now, so I want to briefly go over a few things I may have missed, mostly with object and objecttype arrays.

first, with s you can create or destroy objects by name(remember o.({"address"}) for objects, and ot.({"address"} for objecttype expressions return the name of the type). These are similar to the regular Create and Destroy functions, except now you can destroy by name, and when you create, you have full control over whether the object is picked and how it is picked.

There is a Pick Object condition, and action. Choose whichever works in the situation. All it does is pick whichever object you choose, and gives you options for how it is picked.
There is a "pick all of objecttype" action. Which I hope to add to later. For now, it picks everything of that type, which is basically like resetting the picking for that object.

there is a Set Position/Dimension/Angle action that let's you change the x,y,z,width,height,and angle of an object with a single action. you can choose to keep anything the same by simply leaving the default "same" string there instead of giving a numerical value.

This action serves several purposes:
first, the object doesn't have to be selected at all. This works with the array location of the object. You can move around many objects in complex ways without regard to picking. Having this all in one action reduces clutter on your event sheet, and it is also much faster in large doses, since the event system only has one call's worth of overhead. This can be especially useful in arrays of objects, and loops.

There is an action to convert an objecttype array to an objectarray, by making a new instance of every objecttype in the array, and putting it into an object array, and there is an opposite command, which takes an object array's types and puts them into an objecttype array.

and lastly, there is a "break loop" action which allows you to break out of a loop. after calling the action the remainder of the actions will still be called, but the loop will exit after the current iteration.

We are at the point in the tutorials that if you find any actions, conditions, or expressions, I haven't explained after this tutorial, please ask..

now, on to the SUPER TUT!!!!(pronounced toot, not tutt)
ok, first here's the download of the new version:
click here to download new version

First we will go over the basic stuff you need to know about supers.
Once again, this tutorial assumes you have read and understand the previous tutorials.
First off, let's remember what a super is.
a string is a container to hold text, a number is a container to hold a numerical float value, an object is a container to hold a reference to an object, and an object type holds a reference to an object type. Supers are containers that can hold any amount of arrays of any of those, and any amount of arrays of other supers.

As an example, there is one master super. And everything we've created in any of these tutorials has been created in that master super ( {""} ). you could have created a superarray with one super in it called "mysuper". And everytime you placed a new array instead of saying to place it in {""}, you could have placed it in {"mysuper"} ( or {"mysuper,0"} ), and the tutorials would have run the same. The purpose of the super, however, is to serve as customizable containers (like c++ structs), so you can organize your data in meaningful ways.

So let's get started with some real stuff.
first off, we need to look at how we add superarrays:

everything the same as before, use the same action. ignore the object related options. But two parts are significant in the super. First one is Default. I have "mytemplate" entered here. you can also leave it as the default 0, which makes an empty super. We'll come back to how the defaults work for supers. but for now, let's move on to the option that is unique to supers.
Add one default super
This does exactly what it says. After creating the super array, it adds one super. The reason this option is there, is because as you are creating your entire data structure. There's a good chance you'll want to create a single named super, and go right into adding items to it. Often times you will just use the super on it's own, and not use the array as an array at all. Since you need to have a super there to add things into it. it's convenient not to have to add an element to the array as a separate step before you do this.

and that's pretty much all you need to know for the basics. After you create a super, when you want to make a new object array in it, instead of putting {""} for where to put it, you put in the name of your super array.
so you create a superarray "mysuper"
you want to add a number array "nums"
after creating the superarray "mysuper", and adding one default

very simple.
if you want to retrieve the value at index 2, of this number array you would do:
if you added another super to the same super array, and you added a "nums" in it, and you wanted the value at index 2, you would do:
if you added another super to "mysuper", and called it "wow", you could then add to that super with the address
and you could access a "nums" array in that as well
you can embed as many supers within super as you want. This can be used to create characters that have names, and a sprite, and an array of objecttypes in their inventory, and hitpoints, a list of friends, etc. The possibilities are endless. Any type of logical structure that works in your head, you can now arrange your data in construct that way. That's the purpose of the super.
let's have a quick reminder about pointers now
there is an action "set pointer"

this would create a pointer to that address (for anyone curious, no, it's not an actual c++ pointer underneath)
the pointer is just a shortcut.
after doing that, when you wanted to access that pointed location:
{"mysuper","wow",2,"this could get complicated","are you serious?",2,"oh man, this is crazy"}

you could just type
"p" is a special character used for accessing pointers.
pointers are not aware of their type, you can point to a certain object:
and that would point to the 4th number
and use this anywhere you'd use a number address
or you can point to an array:
where the pointer could point to either the first number in nums, or the array itself
and if you point to a super
you can continue off of a pointer address, for instance...back to this:

let's say "oh man, this is crazy" is a super
and inside "oh man, this is crazy", there is a number array called "nums"
it would be valid to say Add a Number to
you can make pointers to pointers
so this is valid:

they are infinitely recursive, so you can have pointers to pointers to pointers, ad infinitum

back to basic looping one more time here
remember that to refer to the array that is being looped
you can use {"l","loopname"}
with supers, if you are looping through {"mysuper","wow",2,"this could get complicated","are you serious?",2,"oh man, this is crazy"}, and "oh man, this is crazy" contains a number array called "nums"
you can refer to nums similar to the pointers {"l","loopname","nums"}
in this way you can do a loop on a superarray, and then within each super, loop through it's arrays

also you can use a pointer as your looping address, and have a pointer point to loop {"l","loopname"} address, and a loop address be a pointer, once again these can be used within oneanother infininitely.

a few other quick notes before we move on to the real meat of the tutorial,
when you "set pointer", if there is no pointer with that name, it is created, if there is, it is overwritten. you can reassign pointers as you see fit, and use them as variables that can point to any type of data. I will give some advanced examples, but they can safely be used as simple shortcuts, when you don't want to type the same long name out over and over.

for example, you could make a pointer "temp", that you use any time you want to use a shortcut, and just reassign and reuse it to point to arrays, or numbers, or other pointers, whenever you need a new shortcut. or you could do something more complex, and have the pointer actually change to different supers you want to remember for different purposes. Also, keep in mind that this array notation {"this","that",0,"and the other"}
is just strings and numbers, just as you can use an expression for the numbers
you can use an expression for the strings
you could have an array of strings called "mypointers"
and then do this:

another advanced concept for those brave souls, is to keep in mind, if needed you could name arrays using string expressions. These are not private variables, you are free to use any tricks you want with strings to manipulate them.

OK, now for the realness. After this tutorial, it should become obvious that 's' completely redefines the boundaries of what is possible with construct. And all future tutorials will either be to introduce new functions, or to give other ideas of applications. Please feel free to request "could you make a such and such editor" or a "such and such system", and it may possibly be a future tutorial.

first here is the cap:
try the exe of the cap, drag some stuff onto the board, choose the character start location, and save it. it will automatically launch the saved filed so you can look at it. then either restart the exe, or move stuff around, and add stuff, and then hit load, and everything is set back to your save.
let's look at the layout editor:

the items at the upperleft are all of family blue.
the load, and save buttons, the guy, and the line are not
neither is the dummy sprite that is off screen.

in start of layout:

we make an object array called "menu"
then we make a super called "level"
then we add an object array called "objs" inside "level"
first we add the player sprite to {"level","objs"} (which will store our level)
after that we loop through all the blue objects, and add each one to "menu" (which will store the objects you can add to your level)

On drag start - blue (the one's on the top left of the menu)
for each object in "menu", and we names this "menudrag", and do not alter picking
if {"menu",.li("menudrag")} (the current object in the "menudrag" loop)
remember, we just added each object at the beginning to "menu"
if {"menu",.li("menudrag")} is picked as "blue"
(basically, if anything in "menu" is the one being dragged)

if you remember the exe, each time you drag an item from the menu,
it seems like you're getting a new copy fullsize, and the original is staying there.
here's how this part works, I'll paste it again, for easy reading:

we create a new object of type .tt("blue") that is the true type of the picked "blue", and we create this new object at the same location as the picked "blue"
now, we don't want all type of extra steps to make dragging take over a new object
so we put the new object which is now picked as whatever the true type of "blue" is (.tt("blue"))in "menu" at .li("menudrag"), so were replacing the "menu" item we are dragging with the new one we just created. Now the new one replaces the one in the array of the one we just started dragging.
and the one we just started dragging is "blue", so we add that to {"level","objs"}
and make it the original large size.

ok, our level editor is complete except for saving and loading:

when you click on the save sprite:
the first action is:

this is a shortcut to save you time for a common task
it creates a super for you that contains whatever object spacial info you choose, for an entire array of objects
first you choose an object array, in this case {"level","objs"}, where we've been saving the objects we've added to the level.
then you choose where to create the new super, you can choose an actual super address, or "same"
so it creates the super in the same place as the object array you chose, in this case {"level"}
so in this example we choose x,y, length and height
you choose a name for the new super, in this case it's "pos"
and you choose a default value for the super, in case you were planning to use it for other things
you don't need to know this to complete the tutorial, but it may be useful later:
the contents of the super are number arrays with the same number of elements as the object array you choose
the names are "x","y","z","w"(for width),"h",(for height)", and "a"(for angle)
it only creates the arrays for the values you chose to include
when you choose the object array, before you type anything in, the default is "leave empty", this will create the super, and the number arrays, but not input any of the values into the array
since we chose an object array, "x" will be filled with the x values of the objects at the same position in the array, "y" with the y values, etc.

here it is again:

the next action is Save Super:

you choose a filename (doesn't have to be txt, should be something else actually)
the address of the super you wish to save
the type you would like to save MUST BE superarray. I will either add the other options, or remove the option. And furthermore, it is only saving one super...not superarray...for now, just think of this action as Save Super
This isn't limiting though, since you can add any array to a super, and if you choose {""} it will save everything.
The last option is Encrypted
the encryption is secure enough to trust your game info with. Someone who can get around the copy protection of a game could figure it out. But not your average joe. You can safely save scoretables, character info, dialogue, levels...anything. We choose unencrypted in this case, just for the hell of it.

Before we move on. please understand. This allows you total power to save any type of data. If we wanted to add dialogue strings, or numbers for the starting force of physics objects, or object path info, basically you can make any type of gamesave data, or any type of editor, and not worry about the saving part. you could make a 3d mesh editor, an ai logic editor, an in-game movie editor. Creating editors, which was previously a very involved, technical, and tedious task is now as simple as using the save action, once you put things in your super.

I only included the file object for this purpose, to load the file we just saved, so you can look at it. You do not need the file object to load and save. If you are curious, change the save to encrypted so you can see what the encrypted file looks like.

after this we delete the "pos" superarray, since we don't need it. On a side note, there is an action to Add/Overwrite the these object positions/dimension.orientation supers, so you can store this information and use it for other purposes other than saving it.


first we clear the object array. there is an option to "destroy all objects"
so this functions as a simple way to get rid of all the objects on the current level
next is load super "levelsave.txt"

filename, we know
encrypted must be the same as the file was saved or it will not work, and will most likely crash
Load objects as types
the options are No, load as new instances, or if it is useful for whatever reason, you can load them as their types in an object type array. when you save an objectarray, you are only saving what objects they are. Information like location, and plugin info is not saved. just what type of object it was. this is why we put the location information in the super to be saved as well.
choose a super to load it to. ALL INFORMATION IN THIS SUPER WILL BE OVERWRITTEN by the loading action.
and layer to spawn objects, so if you don't load them as types, what layer are we going going to put them on?

finally we have the apply spacial info action:

choose an object array, choose an array made with one of the Object Position, Dimensions, Angle actions, and viola! All the spacial info is applied to the object array. It is important to store and apply the same exact info, you cant store y, and angle, and then apply only angle. for now, it ignores the names of the arrays, which is slightly faster. if there is a huge need to be able to apply partial info, just save the info to separate supers. At the end you have the option to Delete the Spacial info super after applying. you can delete just the single super, or the entire array. This is just a matter of convenience for just this type of situation, where you just want to use the info once, so you don't need a separate action.

just for fun, and practicality, here's a level loader:

single event. the objects have their in-game behaviors on.
take a look, for it to run, you'll have to have already saved a level

well, enjoy your newfound power
feel free to ask questions, especially of the "would it be possible to..." variety

things I forgot earlier:
Templates, the default values of supers->
there is a Create New Template action. You name the template in the action and that is it.
the template is simply a super.
to get to this super, you use the notation {"t","templatename"}
you can use any normal action on a template.
you add all the arrays, you need, it can be as complex as you wish.
when you create a super, you can use a template as the default.
it is not advisable to add objects to this array, because they can be destroyed from somewhere else, but remember you have the action to convert an objtype array to an objectarray.
you can fill your template with empty arrays, or they can have values in them. Whatever is most appropriate, you may have a "character" template that starts with certain items in their inventory, but no entry in the name string array for instance.
when used as default for superarrays, they are created as copies of the templates in the normal way and under the normal circumstances defaults would be created and used, except when attempting to access outside the range of the superarray, which is simply not supported or accounted for.
This will be expanded later to give you more options, but as of now when saving, all template are automatically saved. When loading, all current templates are automatically deleted, and replaced with the contents of the save file.

and lastly, there are new s.ipx({"objectaddress"}), and s.ipy({"objectaddress"}) functions like the s.x({"objectaddress"}) and s.y({"objectaddress"}), except these return the imagepoint x and y values of the object.

have fun
Spriter Dev
Posts: 3,235
Reputation: 16,326

Post » Wed Oct 28, 2009 5:05 pm

wow, looks really good but sadly it does not work for me.. downloaded the new version of plugin and then i download that and run it. Crashes.. the past tutorials work really good. Just this one crashes and when i look at event sheet Construct crashes?
Posts: 49
Reputation: 1,098

Post » Wed Oct 28, 2009 5:19 pm

the new version is only downloadable in this last tutorial post for now. the other links in this thread are still to the previous version.
if thats download s2.rar doesnt work with this latest tutorial, or if it works with the others, somehow, i messed up the upload, and ill fix it when i get home in a few hours.

but yeah, if you downloaded it anywhere but at the top of this latest tutorial, its a different version.im keeping the old version for now, until i remake the caps to work with the new version
Spriter Dev
Posts: 3,235
Reputation: 16,326


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest