Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Pages: 1 [2]  All

Author Topic: New to WME scripting  (Read 14950 times)

0 Members and 1 Guest are viewing this topic.

ciberspace

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 116
    • View Profile
    • Tele Juego
Re: New to WME scripting
« Reply #15 on: March 11, 2013, 03:05:52 PM »

in scene_init.script

Code: WME Script
  1. if(!State*******.Visited)
  2. {
  3.   State*******.Visited = true;
  4.  
  5.   // this is our first visit in this scene...
  6.  
  7. }
  8.  

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #16 on: March 12, 2013, 11:57:57 PM »

Hello, thank you you Ciberspace. That tells me where - So how would I place my "interacted with" code in there? would  it need to say...

if boulder fell, then stay fallen on last animated frame of sprite - if not then stay as original.

and if condition of sorts.

Regards, :)
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: New to WME scripting
« Reply #17 on: March 13, 2013, 07:09:54 PM »

You would need to use your own scene variable, similarly to "Visited". I will use the default scene_init.script as a template to

Code: WME Script
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // scene state
  3. global StateScene1;
  4.  
  5.  
  6. // default values
  7. if(StateScene1==null)
  8. {
  9.   StateScene1.Visited = false;
  10.   StateScene1.BoulderFell = false;
  11.   // add scene states here
  12. }
  13.  
  14.  
  15.  
  16. ////////////////////////////////////////////////////////////////////////////////
  17. // setup scene according to state variables
  18. if(StateScene1.BoulderFell)
  19. {
  20.    //set sprite frame to last
  21. }
  22.  
  23. ////////////////////////////////////////////////////////////////////////////////
  24. if(!StateScene1.Visited)
  25. {
  26.   StateScene1.Visited = true;
  27.  
  28.   // this is our first visit in this scene...
  29. }
  30.  

So you have a global variable StateScene1 which will contain the variables that describe the scene state. When you first visit the scene the variable is null, therefore the initialization code inside the first "if" is executed. Then, when the boulder falls, you must assign true to StateScene1.BoulderFell.

This way, next time you visit the scene, the variable will still be true, therefore the code of the second "if" will be executed, setting the sprite to the last frame.

There are other ways to achieve what you want (which I have tried and made my life complicated  ::)) but I believe the way I described above is the best to handle the scene state.
Logged

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #18 on: April 02, 2013, 11:08:09 PM »

Thank you

Excellent! I will have to put that into practice! it seams to make sense to me, thanks.

Another question.
I was wandering how to go about making an item from your in work with scene object?

Example, select stone > throw stone at wall (plays animation), wall caves in, object vanishes from inventory.
You can then move into a new walkable area?

;-) any pointers?
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #19 on: April 07, 2013, 08:54:42 PM »

Hello, I have been having a crack with setting up the if condition in the start of the Scene_init, think it will take quite a bit of getting my head round as I was getting a scene script error .... sigh... With my boulder I have used a 'play' and 'pause' function with my boulder anim do how do you make a sprite anim jump to certain frame? sorry, i'm new to WME

Thanks,
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/

dongo

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 29
    • View Profile
Re: New to WME scripting
« Reply #20 on: April 08, 2013, 03:41:54 PM »

hello i am spannish, but i am try to help you, you have the atribbutte CurrentFrame of the objet sprite ( sprite_var.CurrentFrame), with this attribute, you can Specifies the index of the currently playing animation frame.
Logged

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #21 on: April 09, 2013, 10:49:42 PM »

Thanks
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/
Pages: 1 [2]  All
 

Page created in 0.039 seconds with 24 queries.