'S' update as of 4/12/11

New releases and general discussions.

Post » Sun Dec 27, 2009 2:55 pm

scidave, your answer is in the previous post


for anyone who read my longwinded explanation of how to find the python commands for a plugin.
I just rerealized. you can just type 'objectname.' in the python script editor to get a list of every command and parameter :lol:
much simpler
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Dec 28, 2009 5:20 am

Lol, yeah that helps a lot :D Somebody should really add that tidbit to the wiki page about Construct python scripting...
B
2
G
3
Posts: 11
Reputation: 872

Post » Thu Dec 31, 2009 4:06 am

@lucid - Thanks, that did the trick! I now have the example working. I understand at least partially why the tt example wasn't working as well. However, still get crashes when I try to fix it. I haven't installed the old version to better see how they work so I won't blindly ask you to fix it. Hopefully I'll get some free time this weekend and figure this S thing out. :D

One interesting thing I noticed is that you can no longer spawn another object with editable expressions like in your old example. The only way now is with a system create object by name action.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Jan 22, 2010 3:13 am

Hi Lucid,

I'm trying to work again with S on this inventory thing. Here is the general idea.

The player has X number of equipped item slots (3 in this case) and a large area where inventory items can be kept (bag or case). When the player goes around and touched an item it is added to the case. If the player then switches to inventory mode they will see all of the items they have touched in the bag. They then have the option to equip and unequip items. When they equip an item the icon for that item displays in the equipped slot.

Of course, this could also relate back to the player. If they have certain items equipped then they could have those actually spawned with them (like a knife vs sword) or a magic spell.

Ok, that is the main idea. I've attached a .cap with a really rough implementation that is just really bad and doesn't work well. It crashes unless I switch to inventory mode before having the player run over the item. I completely do not understand that crash. It also doesn't work if more than one item is in the family. I thought one of your example used just the object kinda like what I am doing here (even though the family is specified). I clearly do not understand S right now.

Also, unrelated to S do you know a way to "pick object by name". For example, if the global var # of equipped is 0 I would like the equipped0 panel to display using something like (object name = "equipped&global("equipped").

Here is the .cap:
http://www.box.net/shared/g3sf71mjl2

Thanks for any feedback.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Jan 24, 2010 4:09 pm

[quote="scidave":peznt919]Hi Lucid,

I'm trying to work again with S on this inventory thing. Here is the general idea.

The player has X number of equipped item slots (3 in this case) and a large area where inventory items can be kept (bag or case). When the player goes around and touched an item it is added to the case. If the player then switches to inventory mode they will see all of the items they have touched in the bag. They then have the option to equip and unequip items. When they equip an item the icon for that item displays in the equipped slot.

Of course, this could also relate back to the player. If they have certain items equipped then they could have those actually spawned with them (like a knife vs sword) or a magic spell.

Ok, that is the main idea. I've attached a .cap with a really rough implementation that is just really bad and doesn't work well. It crashes unless I switch to inventory mode before having the player run over the item. I completely do not understand that crash. It also doesn't work if more than one item is in the family. I thought one of your example used just the object kinda like what I am doing here (even though the family is specified). I clearly do not understand S right now.

Also, unrelated to S do you know a way to "pick object by name". For example, if the global var # of equipped is 0 I would like the equipped0 panel to display using something like (object name = "equipped&global("equipped").

Here is the .cap:
http://www.box.net/shared/g3sf71mjl2

Thanks for any feedback.[/quote:peznt919]
sorry for the slow reply
here:
[url:peznt919]http://dl.dropbox.com/u/1013446/inv2.cap[/url:peznt919]
the most important thing to remember when dealing with objs and objtypes is to recognize and remember the differences
it's definitely a little strange at first, because in construct you normally never have to think of the differences. The idea of S is to give you some of the same abilities you have when making a plugin in c++.
so if you want to remember what "kind" of object, that's an object type
you can create and object of an objecttype, or select objects of an objecttype, or even check if an object is of an objecttype

if you want to remember an actual object, that's object
objects are things on the screen, that can be moved around, destroyed, have behaviors on them, etc.

when you put the objects in the array, then you destroyed the objects, the array was remembering objects that were no longer there. To avoid this, when destroying objects inside an array, use the delete object action. This allows you to destroy the object and delete it in one step

for in an inventory, however, where you don't want the object on the screen, you just want to remember what type of object it is, that's an objecttype. please try the example, and let me know if you have any more questions.

one of the things I hope to eventually add to 's' is a debugging feature, where instead of crashing, there can be an "on error" condition, and a "geterror" expression, so you can set a textbox to the error, and see why it's happening. should make it easier to learn, and to find mistakes. that's a little further down the line though.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sun Jan 24, 2010 8:16 pm

Thanks for the help!

[quote="lucid":1dlde57l]one of the things I hope to eventually add to 's' is a debugging feature, where instead of crashing, there can be an "on error" condition, and a "geterror" expression, so you can set a textbox to the error, and see why it's happening. should make it easier to learn, and to find mistakes. that's a little further down the line though.[/quote:1dlde57l]

This would be a HUGE help. I keep wanting to look at the S object in the debugger to see what is being populated. Any extra bit of debug info would really help in understanding S. This plugin is so incredibly powerful!
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Thu Jan 28, 2010 10:15 am

Hey lucid, the code I posted for you yesterday didn't work So I rigged the same situation in a cap as an example so hopefully you or someone can notice what I did wrong!

http://kayin.pyoko.org/saveexample.cap

This is sort of a proto example of a save file format for my next game. Save stores all info and then there are superarrays within save, such as general. General keeps track of a few number arrays like x and y position, game time and deaths. General would have an index between 1 and 4 for each saved game.so {"save", "general", 1, "x"} would give the x value in generals saved game 1 slot.

In this example, I keep save and general and only work with x.

1 saves, 2 restores. Q and W add and subtract from the save slot. Text on the right tells you what save slot it's on, text on the left gives the x value in general 0 through 3.

When you press to save, ALL VALUES get set to your position, which is clearly wrong. Lucid said my code looked fine when I gave him a screenshot of it, but clearly something is up!

Any help will be appreciated, I've tried a million different things and 999,000 of them crash S. :|
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

Post » Sun Jan 31, 2010 11:47 pm

I'm too lazy/busy at the moment to update all the links
this is the latest version of 's'
[url:3345ha65]http://dl.dropbox.com/u/1013446/s/sdebug/s.rar[/url:3345ha65]
there are some more added features and bugfixes I won't document at this time
if you have any questions how to use something new though, please ask, although you may have noticed my answers are getting slower due to my current development/time management situation.

anywho, the particular reason for making this current update public are the new debugging features.
3 new actions:
[list:3345ha65][*:3345ha65]set debug text output path.[/*:m:3345ha65]
[*:3345ha65]set/add debug text.[/*:m:3345ha65]
[*:3345ha65]clear debug text.[/*:m:3345ha65][/list:u:3345ha65]
set debug text output path, sets the output path and filename of the debug log. you can set whether or not you want the file to automatically launch the debug file when an error occurs, if you set this to "yes", and your file is a text file, such as "c:\users\you\desktop\debug.txt", this will load the debug file in notepad as the error occurs

set/add debug text, let's you set your own text to go in the debug file, there is an option to either set the text, which clears all text, and sets it to the string you choose, or append, which will keep the current text, and add the string you choose to it. This is very useful for determining where an error occurs. For instance
[code:3345ha65]-**Start of Layout**
---SET Debug Text to "Start of Layout"
---Do whatever

-**On Left Mouse Clicked**
---SET Debug Text "Left Mouse Clicked"
---Do something
---**Mouse is Over Sprite**[/code:3345ha65]
------APPEND Debug Text "Mouse over sprite"[/code]
------Do something else
if a crash occurs now it is easy to determine in the log where the crash occurs

Clear Debug Text simply clears the debug text, you usually will not need this, since Set Debug Text will clear it for you.


's' is extremely stable, and doesn't crash unless there is a user created error. even if I added code to prevent the crashes, it would still mean that you would not achieve the desired result you were looking for, and would require a massive rewrite that would probably reduce the efficiency of the current code.

as of now the debug does not log errors that are related to trying to access an object that has been destroyed.

using these new features today, probably saved me a few weeks work from what it would have taken without the new debugging features...

finally, kayin, sorry for the late reply, I'll take a look at that now
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Feb 01, 2010 12:00 am

those looking for info on the new debugging feature check out the post just before this one

Kayin:
k, first problem, is in Start Of Layout, you added "x" to {"save","general"}
but you never created the super array "general"

for the remainder of the cap you're doing {"save","general",global('slot'),"x"}
this will work if you add multiple "general" supers, and you want to access each one
which now that I think about it is probably what you wanted to do, however,
in the update to your example posted below, I have one "general" super, with many possible numbers in the "x" array:

[url:35gh0g1f]http://dl.dropbox.com/u/1013446/saveexample2.cap[/url:35gh0g1f]

read up on super templates if you want to use default supers, they work a little different than everything else, and caps should be planned accordingly.

btw, just for general info's sake, when you attempt to add an array to a super that doesn't exist, it adds it to {""}, I haven't tested it yet, but I believe this error will be caught by the new debugging features.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Feb 01, 2010 4:27 am

This doesn't work either. While it doesn't write to all positions at once, this time it won't write to any position outside 0. :|

Even if I hardcode in a slot number. I ever cut down everything to a single number array in an attempt to write to a particular index. It was a failure. This really seems like something is broken.
B
12
S
4
G
4
Posts: 238
Reputation: 2,426

PreviousNext

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 4 guests