scritping simply

A place for tutorials on how to get the most out of Flash

Re: scritping simply

Postby BlueLight » Tue Aug 12, 2014 7:29 am

sorry but this is beyond me.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: scritping simply

Postby Terrantor!!! » Thu Aug 14, 2014 12:05 am

What's Bash?
Mi amigo! I don't understand what you are trying to do with your two timelines. However, if that second timeline is contained within an mc, all you need to do is assign an event listener to gotoAndStop a certain frame on the container when the listener is satisfied. Alternatively do you know how to create functions? I'd probably make a function on your main timeline so that it could be called anywhere in your game. it would look something like Blue's code and you'd add this script to frame 1 on your main Timeline in the code layer:

Code: Select All Code
/*it's been a while since i coded in as2, so there may be some mishmash with declaring variables.
however, if it ends up not working just delete ,"var," and the datatype declaration ":Boolean" or ":int" and :etc.*/

function runStoryorWhateverYouWannaCallYourFx(storyNumber:int){

     switch(true){
          case _root.sex==2:  //_root.sex can be "male" or 2 depending on the datatype you decide to use;
                 spriteInstanceName.gotoAndStop(_root.sex)
                 story.gotoAndStop(storyNumber);
          case _root.sex==1:
                 spriteInstanceName.gotoAndStop(_root.sex)
                 story.gotoAndStop(storyNumber);
          case _root.sex==0:
                 spriteInstanceName.gotoAndStop(_root.sex)
                 story.gotoAndStop(storyNumber);
    }
}


Then alls you needs to do is type _root.runStoryorWhateverYouWannaCallYourFx(desiredStory); Just make sure you've handled what _root.sex is before-hand and your sprite has the proper frames and labels if it's a string datatype.
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: scritping simply

Postby Zeus Kabob » Thu Aug 14, 2014 7:31 am

Terrantor!!! Wrote:What's Bash?


Just the best shell ever. The Bourne-again Shell (Bash) is the successor to the Bourne Shell (sh), and it's a command-line interpreter (cli) that has full scripting capabilities and uses a system $PATH variable to locate and run executable programs and using the unix/linux stdin, stdout, and stderr to redirect program input and output through the scripting process.

At the end of the day, it allows you to do cool stuff like search your entire filesystem for a specific filename, search a directory for every file with a certain thing in it, and some other cool things.

Code: Select All Code
find / | grep myfile.txt | xargs rm
//this looks through the entire system (/ and all subdirectories), sends all of the file paths to grep, which checks if they contain the string "myfile.txt".  Anything that satisfies this gets sent to the program "rm", which removes it from the system.

diff oldfile newfile -u > temppatch; patch patchme < temppatch; rm temppatch
//Use the differences between oldfile and newfile to create a patch between them, then apply that patch to patchme, then remove the patch file. 

"myscript.sh"
#! /bin/bash
d=date --iso-8601
if [ $(ls | grep $1) -n] then
cp $1 ~/archive/$d.$1
python ~/bin/myscript.py -c $1
fi
//a little script that runs a python script on the file you specify (by running "myscript.sh myfile") and archives it (using iso-8601 date format, i.e. 2014-08-14.myfile). 


Bash is pretty cool. I like.
User avatar
Zeus Kabob
Moderator
 
Joined: Tue Nov 16, 2010 2:16 am
Location: Between some awesome thunderheads

Re: scritping simply

Postby Terrantor!!! » Fri Aug 15, 2014 6:17 am

Ahh, I've admittedly never dealt with a LUI, however I will be taking a course on Linux as part of my curriculum later next year so that'll be a good primer.
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: scritping simply

Postby hat973 » Sat Aug 16, 2014 6:14 am

And i still dont understand iv read it ten times
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: scritping simply

Postby Terrantor!!! » Tue Aug 19, 2014 5:48 am

which part is causing confusion? Read the entire script from top to bottom and as soon as you see something that causes confusion, put it on a list. copy that list down and post it, I'll go over it all.
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: scritping simply

Postby hat973 » Tue Aug 19, 2014 11:11 am

just the .sh bit i dont understand is that flash or not
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: scritping simply

Postby Zeus Kabob » Tue Aug 19, 2014 12:21 pm

hat973 Wrote:just the .sh bit i dont understand is that flash or not

Nope. It's a couple examples of scripting in Bash, which is not related to Flash in any way.
User avatar
Zeus Kabob
Moderator
 
Joined: Tue Nov 16, 2010 2:16 am
Location: Between some awesome thunderheads

Re: scritping simply

Postby hat973 » Wed Aug 20, 2014 5:45 am

idk what bash is like 100% do not know
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Re: scritping simply

Postby Zeus Kabob » Wed Aug 20, 2014 6:27 am

hat973 Wrote:idk what bash is like 100% do not know

Zeus Kabob Wrote:
Terrantor!!! Wrote:What's Bash?



Just the best shell ever. The Bourne-again Shell (Bash) is the successor to the Bourne Shell (sh), and it's a command-line interpreter (cli) that has full scripting capabilities and uses a system $PATH variable to locate and run executable programs and using the unix/linux stdin, stdout, and stderr to redirect program input and output through the scripting process.

At the end of the day, it allows you to do cool stuff like search your entire filesystem for a specific filename, search a directory for every file with a certain thing in it, and some other cool things.


If you've ever used the DOS COMMAND.COM cli or the modern windows cmd.exe command line, Bash is very similar to those. In Mac, the program called "Terminal" runs Bash.
User avatar
Zeus Kabob
Moderator
 
Joined: Tue Nov 16, 2010 2:16 am
Location: Between some awesome thunderheads

Re: scritping simply

Postby BlueLight » Wed Aug 20, 2014 6:33 am

Zeus Kabob Wrote:If you've ever used the DOS COMMAND.COM cli or the modern windows cmd.exe command line, Bash is very similar to those. In Mac, the program called "Terminal" runs Bash.

if you don't know what CMD.exe is, and have a modern windows, click start and in the search box type "CMD" in. Should work for Vista or above.
If you are using XP then their should be a icon that says "Run", click that and type in CMD.
User avatar
BlueLight
Gangs n' Whores Developer
 
Joined: Sat Jun 04, 2011 8:23 am

Re: scritping simply

Postby Terrantor!!! » Wed Aug 20, 2014 10:12 pm

Yesh. But let's keep this on topic guys. He's working with actionscript. Though I wouldn't be against an LUI tutorial in this section.
User avatar
Terrantor!!!
 
Joined: Thu Aug 23, 2012 10:36 am

Re: scritping simply

Postby hat973 » Sat Aug 23, 2014 6:00 am

Spoiler (click to show/hide):

Code: Select All Code
// test variables
var player_health:Number = 50;
var player_name:String = "Coozy";
var player_dead:Boolean = false;

// create save data object
var saveData:SharedObject = SharedObject.getLocal ("test");


///// SAVE FUNCTION /////
function game_save () :Void
{
     // clear current saved data
     _root.saveData.clear ();
     
     // record variables
     _root.saveData.data.player_health = _root.player_health;
     _root.saveData.data.player_name = _root.player_name;
     _root.saveData.data.player_dead = _root.player_dead;
     
     // save as cookie (without using this method, the cookie will disappear after the current browser session)
     _root.saveData.flush ();
}


///// LOAD FUNCTION /////
function game_load () :Void
{
     // load saved data
     _root.player_health = _root.saveData.data.player_health;
     _root.player_name = _root.saveData.data.player_name;
     _root.player_dead = _root.saveData.data.player_dead;
}


///// CLEAR SAVED DATA FUNCTION /////
function game_clearSave () :Void
{
     // clears saved data in built-in method
     _root.saveData.clear ();
}


me and Vintage found this code and im wondering with a dating sim is there anything id need to code diffrent i mean i know ill have to put other code in like bells and relashinships but anything im missing here
Red light panda

:ugeek: Tumbler: Tumbler
:geek: I have a Blog: Red Light Blog
;) I stream to Give me a Watch over at: Picarto
:mrgreen: Donate: Patreon
:roll: Discord:Discord
User avatar
hat973
 
Joined: Tue Apr 24, 2012 12:44 am

Previous

Return to Tutorials



Who is online

Users browsing this forum: No registered users