Extra Utils Extension [2.0.1]

ETHproductions

  • *
  • Posts: 426
Extra Utilities Extension

This is a little extension I (originally) wrote in an hour, with a few blocks I've found myself wanting several times. If you have a block you'd like to have handy, tell me and I'll see if I can add it in. :)

I know that all of the blocks (unless marked otherwise) work on Flash, HTML5, Windows, and Cppia, and they should work on everything else. (If you can test this extension on Mac, Linux or Mobile, please tell me how it works!)
Designed to work with Stencyl v3.4+. Some blocks may not work with Stencyl v3.3 or below.

Features
- if ___ then ___ else ___
- ___ is an actor/a number/text...
- get/set scene value
- exit game (Desktop & Mobile)
- copy to clipboard (Flash)
- save/load game with custom name
- repeat (x: __ y: __ ) times
and a few more...

Download for 3.4+

(How to Install and Update an Extension)
(Legacy downloads: 3.2, 3.3. Please note that these are no longer being maintained.)
(View on GitHub)

If upgrading from the 3.2 or 3.3 version of the extension:
1. Install the extension as usual. Note that it will not overwrite the 3.2 version, resulting in two versions of the extension in your folder.
2. For each game you want to upgrade:
  a. Open the game.
  b. In the Extensions settings, disable the "Extra Utilities 3.2" extension and enable the "Extra Utilities" extension.
  c. Save and close the game. DO NOT open any resources before closing.
  d. Reopen the game. It should now have successfully upgraded.


Blocks



Works just like the if/otherwise wrappers, but returns a value instead of running code. For example:



Can be shortened to:



You can even use multiple if/then blocks inside of each other, which works the same way as using if/elseif/else blocks.




Another little shortcut block I wanted. (a = either b or c) is equivalent to (a = b or a = c).




Returns whether the input is of the selected type.

Note: There are some limitations with this block.
Animations and controls are both stored internally as strings (i.e. text), so "abc" will return true with both.
Also, colors are stored as integers, so 0 counts as a valid color (black).
Shaders are not included at all because anything will return true as a shader.
The map option will always return false, due to an unresolved bug.





This block turns any number into an integer (whole number) using Std.int.




Gets and sets the update speed, in milliseconds, at which the game engine is running (how often physics are updated and When Updated events are run). For coders, this is equivalent to Engine.STEP_SIZE. The default number is 10 (100 fps). Set to a lower value to simulate fast-forward, such as in the Tower Defense games, and a higher value to slow the game down. Does not work with values less than 1.




These blocks work just like the actor value blocks, but stores the values in the scene. This allows you to access values, no matter how many actors you have. (Secret: this actually stores the values as actor values, but on the permanent actor representing the camera.)




Sets the system clipboard, accessed with Ctrl+V. Unfortunately, only works on Flash.

 


Saves/loads the game's save file with a custom name (the default is 'mySave'). Useful for having multiple save files, or default Game Attribute settings.




Works just like the built-in loop block, but works over a 'grid'. This allows you to easily create grid-based structures, or loop over sections of the scene with the Tile API.

Version History
Code: [Select]
2.0.1 (03/03/18)
Fixed a bug causing the game to crash on desktop targets when attempting to save the game with a name containing a space.

2.0 (03/03/18)
Updated for Stencyl 3.4 and 3.5 beta.
Re-added engine speed blocks.
Removed exit game, null, and blank text blocks, as these are now built in.

1.3.1 (02/15/15)
Several blocks now have icons on them, to match the built-in blocks.
Fixed a few unsupported features in the 3.1 version.

1.3 (02/14/15)
Added a 3.3 version, and mostly fixed the 'anything is' block.
Added blocks:
- get/set scene value
- exit game (Desktop & Mobile)
- copy to clipboard (Flash)
- repeat (x: __ y: __ ) times

1.2 (12/12/14)
Updated to 3.2.
- if/then/else block changed to yellow
- save/load succeeded block combined into save/load wrapper

1.1 (11/04/14)
Added blocks:
- ___ is an actor/a number/text...
- __ as int

1.0 - Initial release (10/02/14)
Blocks:
- if ___ then ___ else ___
- ___ = either  ___ or ___
- blank text/null
- get/set update speed (step size)
- save/load game with custom name

If you have any questions, problems, or suggestions, feel free to post them! :)
ETH

« Last Edit: March 03, 2018, 09:57:44 pm by ETHproductions »
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

PhaserRave

  • *
  • Posts: 81
These look great, thanks! I'll have to try them out soon. I'm especially interested in the last two.
"I refuse to answer that question on the grounds that I don't know the answer." -Zaphod Beeblebrox

Photon

  • Posts: 2697
Quote
Another little shortcut block I wanted. (a = b or c) is equivalent to (a = b or a = c).

Just want to point out that the syntax of your block doesn't necessarily line up with typical Boolean algebra. "a = b or c" would normally be translated as "(a == b) or c" where "a = b" and "c" are the two condition of the or-statement. See the difference?
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

ETHproductions

  • *
  • Posts: 426
Thanks, guys! I've changed the syntax for that block to 'if ___ = either ___ or ___'. Does that make more sense?
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

yoplalala

  • *
  • Posts: 1461
Quote
NOTE: These blocks are hidden in the 3.2+ versions. I have another extension coming out soon that will replace them.

I was wondering .. By what will you replace them ? Is another trick than the camera actor value ?

ETHproductions

  • *
  • Posts: 426
@yoplalala: Sorry, I was talking about the "update speed" blocks, not the "scene value" blocks. I had another extension in progress that was supposed to be able to rotate and zoom the camera, as well as set the update speed. However, as it turned out, these other two features will not be fully possible without some modifications to the engine. (I am aware of letmethink's amazing zoom/rotation example, but I'd like to have more control over the camera.) I will try to make these modifications in the next couple of weeks.
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

yoplalala

  • *
  • Posts: 1461
Sorry I'm the one who totally misread ...

But good luck for you new extension. It looks great but sounds difficult !

letmethink

  • *
  • Posts: 2540
I have started making engine modifications to get zooming out to work, so I could point you in the right direction of what you need to edit for zooming out to work engine side.
~Letmethink

Donni11

  • *
  • Posts: 2174
I'm aware this topic is old,

@ETHproductions, is there anyway to have this ability of the block for desktop ?

The Stencyl Discord Channel , Where the real Stencyl work happens ;).

ETHproductions

  • *
  • Posts: 426
@Donni11: I'm sorry, which block do you mean?
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Donni11

  • *
  • Posts: 2174
The Stencyl Discord Channel , Where the real Stencyl work happens ;).

ETHproductions

  • *
  • Posts: 426
I don't think that's possible on desktop or mobile targets, at least not without a native extension. It may be possible with HTML5, using the clipboard.js library. I'll look into adding that to the extension when I get a chance.
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

BMJ

  • *
  • Posts: 278
Thank you for making this much-needed extension!

If I use this extension to create multiple save files - how do I create a menu for the player to choose from the save files that have been created? How can I access the names of saved games to make a list? I would like to display all the names of the save files that have been created and have the player select one with the arrow keys, rather than remember & type in the name of the save file like it's a DOS prompt or something . :)

ETHproductions

  • *
  • Posts: 426
Hey BMJ,

You'd have to create a custom behavior to do that. I don't have time right now to make a working example, but this gist of it is this:

1. Create a Game Attribute array to store the list of save file names.
2. Create an actor that displays this list of save file names. (You could also do it directly in a scene's Events or Behaviors)
3. Add code to the actor/scene that highlights one of the names, and allows the user to highlight different names with the up/down arrow keys. (You could also use the mouse to select an option, but that might be tougher)

Hope this helps! If you'd like I'll try to come up with a working example in the next few days.
Fontstruct - Stencyl - Website (in progress)

Proud Member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

BMJ

  • *
  • Posts: 278
Hi ETH,

Thanks for the previous post - I was able to make just such a behavior and it works well, but ...

... after updating to Stencyl 3.5, the save game wrapper crashes the game and gives an "Error #2134: Cannot create SharedObject" error. Do you know what might be causing this?

(This is a desktop game. The error occurs in both Cppia and Desktop compiles.) Using build 9703. Also worth mentioning - I have also changed computers. The previous was Win 7 and this is Win 10, which I mention because I wonder if it might have anything to do with write permission settings preventing the save file from being created? I don't know too much about that stuff, so I don't know, but I thought it was worth mentioning.

More info - I've downloaded and installed the 3.3 version of the Extra Utilities extension, but the error still happens and Stencyl still says Extra Utilities 3.2 is installed. It doesn't list 3.3 in the extensions pane. (See PNG)

« Last Edit: January 28, 2018, 08:31:21 am by BMJ »