Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: [1] 2  All

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

0 Members and 1 Guest are viewing this topic.

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
New to WME scripting
« on: January 31, 2013, 07:51:13 PM »

Hello all, I have just started re-learn WME, I have completed the tut and now I'm getting my head round it by designing a little 2 level micro game. I'm really impressed with WME and the language reminds me of AS2.

Now i'm getting the stages of scripting and inventory bits - so I thought I would ask the veterans.

for argument sake, if i wanted a "?" to hover over all interactive objects and then you "look at (interact)" and the object becomes discovered (named) so "?" changes to "object name (fork)"
how complicated would that be to manipulate in the code?

Last one in terms of object orientated programming and changing frames. Is it straight forward for to make and object change its state by repeated actions (frame 1 frame 2) or the "if condition" of something on a stage? example: character kicks wall, crack appears, kicks again crack widens, again wider and so on and so on?

Thanks for any help on this.

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

ciberspace

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

Scripts - you can assign one or more script to a sprite; that way you can programmatically control sprite properties, frames and the animation flow

Quote
Sprite object
The Sprite object allows you to access the properties of your animations. Sprite objects can be queried using the GetSpriteObject methods of various objects and their equivalents.



Methods
Actions 
GetFrame Returns one animation frame.
AddFrame Adds a new frame to the animation.
InsertFrame Inserts a new frame to the animation.
DeleteFrame Removes specified animation frame.
Reset Resets the animation.
Pause Pauses the animation.
Play Resumes a paused animation.
Script functions 
AttachScript Executes a script file and attaches it to the object.
DetachScript Terminates a specified script file and detaches it from an object.
IsScriptRunning Queries whether a specified script file is running and attached to an object.
CanHandleMethod Queries whether the object supports a method of a specified name.
::wave

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #2 on: February 03, 2013, 11:38:30 AM »

Hello, Thanks :-) Which one of those methods would resemble an action> next frame of sprite animation or sub frame?. like a button click.

Cheers,  ;D

P.S is is straight forward to see how many scripts you have attached to an object/sprite?
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/

Jose

  • Regular poster
  • ***
  • Karma: 2
  • Offline Offline
  • Posts: 134
    • View Profile
Re: New to WME scripting
« Reply #3 on: February 13, 2013, 03:21:05 PM »

Hi jimm84,

I think both of your questions can be easily achieve using custom properties on the entities. For example you can have one custom property called 'viewed' so while this property is 'false', the caption of the entity will be '?' then when the player look at or interacts with the entity you can change the property to 'true' so from that moment on, the caption of the entity will be 'fork'. The crack on the wall could be handled in a similar way changing the sprite based on the value of a custom property called, for example, 'crack_state'. Also you can raise events from any frame on a sprite that can be handle in the scripts.
Logged

jimm84

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

Thanks Jose, that makes sense. like a said it reminds me of actionscript for flash. :-)
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 #5 on: March 01, 2013, 10:40:18 PM »

Hello all, I'm starting to get my teeth sunk into the scripting stages and was wandering if someone could point me in the right direction, I know ... I'm new! :-) Here goes.

I have a boulder sprite animation that crashes down from a ceiling. The animation plays the moment the screen loads, I would like the animation to freeze on the on the first frame of the animation until ... the boulder is triggered. I keep making references to as2 but it's not.

So...

Animation is paused - then triggered (left click, keep it simple) - and then the animation stays on the ground (last frame)
Thanks for your help. Would I be able to find snippets of code in the resource that could show me how to do simple interactive animation like this? I find it easier to learn by reverse engineering things, ok, breaking things!

Thanks for your help and support! :-)
Logged
Hello! :-) Illustration & Animation Portfolio http://jdillustration.jimmsdesign.co.uk/

appaul

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: New to WME scripting
« Reply #6 on: March 02, 2013, 08:13:23 AM »

If you go to sprite editor, and go to frame properties on Frame 1, there's a field called "Event".
Fill that in with, say, "FirstFrame" and then go to Sprite properties and attach a scipt that has:
Code: [Select]
on "FirstFrame"
{
  this.Pause;
}

Then go to your Entity that contains the sprite in scene manager, make sure it's interactive and attach this:
Code: [Select]
on "LeftClick"
{
  var boulder = this.GetSpriteObject();

  boulder.Play;
}

I haven't tried it, but I think that should work.
As for freezing on the last frame, just make sure "Looping" on the sprite is unchecked. Or do a similar thing as the first step above.
Logged

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #7 on: March 04, 2013, 02:18:14 PM »

Thanks a Appaul, I will have a go at applying this over the next few days.

I was wandering with the "firstframe" is labeling the event/function, or are your labeling the object for other pieces of script to reference to? .. if that makes sense.

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

appaul

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: New to WME scripting
« Reply #8 on: March 05, 2013, 01:07:05 AM »

No problem.

You're not really labeling anything. You're creating an "event" on that specific frame, so that when the sprite reaches that frame, the engine looks for the name of the event in the attached scripts and executes that block of code.
http://docs.dead-code.org/wme/scripting_about_events.html
Logged

jimm84

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

Cheers for that! I'm being a nightmare, I had a go at using your script yesterday and I could not get the animation to stop. After a while I even tried "this.Pause;" when the object is left clicked / taken to try and stop a looping animation. This was attached to the object in the scene. 

When I was trying the script no errors were returned... it just did'nt work. Bit stumped, any clues?

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

appaul

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: New to WME scripting
« Reply #10 on: March 06, 2013, 07:31:52 PM »

Sorry, that was actually my bad. I work mostly with 3d actors, so a couple of things slipped past me.

First off, they should be .Play() and .Pause() - with the brackets.

Second, after a couple of tests, it seems like the frame event calls the script attached to the entity and not the sprite. So instead of attaching a script to your sprite, just add the "FirstFrame" event to the entity script, so it looks something like this.
Code: [Select]
var boulder = this.GetSpriteObject();

on "FirstFrame"
{
 boulder.Pause();
}

on "LeftClick"
{
 boulder.Play();
}
Logged

jimm84

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

Hello again, no worries. I had a tinker yesterday with getting an animation to start and stop which worked well when clicked... but not quite how I needed. :) I will have another look over the next few days, I'm working with flat 2d sprites.

I was wandering with the Play(); etc what can be placed in the brackets? frame number?

When you say entity, do you mean in the scene editor?

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

appaul

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: New to WME scripting
« Reply #12 on: March 07, 2013, 07:35:16 PM »

I was wandering with the Play(); etc what can be placed in the brackets? frame number?
Nothing. I believe that's just the format for functions and methods.

When you say entity, do you mean in the scene editor?
Yes. You attach the script to the entity in your scene that's using the animation.
http://docs.dead-code.org/wme/inside_entites.html
Logged

anarchist

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

Most programming languages I have worked with use this format of calling functions and methods. That is, all functions need () when they are called. So, a function that takes two arguments is called:

Code: WME Script
  1. function1(argument1, argument2);

while a function that takes no arguments is called:

Code: WME Script
  1. function2();

In WME, if you call an object like this:

Code: WME Script
  1. object.function();

it means you want to call the function named "function" inside that object, that takes no arguments. On the other hand, if you do this:

Code: WME Script
  1. object.Something;

then you are referring to the object attribute named "Something".
Logged

jimm84

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
    • JD Portfolio
Re: New to WME scripting
« Reply #14 on: March 10, 2013, 07:38:53 PM »

Thank you both, I'm becoming a bit more familiar with it now! So exciting. I've made a boulder play when clicked... and freeze when finished. The boulder becomes an island basically, but now... how do I get the scene to remember that the boulder has been interacted with?

When the character leaves the room and comes back everything returns to its original state?

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

Page created in 0.064 seconds with 21 queries.