Need help with quick spawning

About advanced scenes, and the Thyme scripting language used in Algodoo.

Need help with quick spawning

Postby Rideg » Sat Aug 14, 2010 3:04 pm

Hello. I'm making a gun that I'm doing a muzzle flash efect on. I need to spawn a box with the muzzle flash texture.
I need this box to rise it's color value from color(3) = 0 to color(3) = 1 and then back to color(3) = 0. And when it's lower than color(3) <= 0.0 it will delete itself.

I've heard of dynamic variables but I could really get it to work. Perhaps if I got it explained for this problem I might understand. Please share your expirience to a lesser knowing being :P

Thank you :)
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Need help with quick spawning

Postby Matten » Sat Aug 14, 2010 5:22 pm

For a spawned geom with dynamic variable you need to use "geval".
To use type: "geval(*spawning code(including dynamic variables) as string*)"
So if you spawn a circle with dynamic HSVA color you can use:
Code: Select all
geval("Scene.addCircle({color := {[sim.time, 1, 1, 1]})")
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Need help with quick spawning

Postby Rideg » Sun Aug 15, 2010 1:07 am

I'll try that. haven't used geval before :P
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Need help with quick spawning

Postby Rideg » Sun Aug 15, 2010 1:14 am

Well I can't spawn it. Here's the code:
Code: Select all
(e)=>{
    geval("Scene.addBox({
        color := {[sim.time, 1.0, 1.0, 1.0]};
        drawBorder := true;
        textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0, 0.1736111, 0.5442616, 0.0, 0.0, 1.0];
        texture := "Muzzle_Flash_Side.png";
        collideSet := 0;
        zDepth := +inf;
        geomID := 10233453;
        pos := e.pos;
        angle := 0.0;
        size := [6.26, 1.75]
    })")
}


This is my error message:
Code: Select all
-- Warning: Caught exception: Line 2: Newline in string literal, Source\script\Parser.cpp:174: class SharedPtr<class script::CodeBlock> script::Parser::Parse(const util::String &,class SharedPtr<class script::Reflected>)
Tokenizer error: Line 2: Newline in string literal
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Need help with quick spawning

Postby REMqb » Sun Aug 15, 2010 1:24 pm

When you want to use " in a text string you have to add the escape character \ before it.

Code: Select all
(e)=>{
    geval("Scene.addBox({
        color := {[sim.time, 1.0, 1.0, 1.0]};
        drawBorder := true;
        textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0,
0.1736111, 0.5442616, 0.0, 0.0, 1.0];
        texture := \"Muzzle_Flash_Side.png\";
        collideSet := 0;
        zDepth := +inf;
        geomID := 10233453;
        pos := e.pos;
        angle := 0.0;
        size := [6.26, 1.75]
    })")
}
REMqb
 
Posts: 15
Joined: Wed Dec 30, 2009 7:51 pm
Location: France

Re: Need help with quick spawning

Postby Rideg » Sun Aug 15, 2010 2:45 pm

How can I deal with newlines? I can't spawn unless I remove every newline and I don't want a scrambled text :S
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Need help with quick spawning

Postby Matten » Sun Aug 15, 2010 3:28 pm

As far as I know this isn't possible, you just need to get used to it...
Cave Johnson wrote:Do you know who I am? I'm the man who's gonna burn your house down! With the lemons! I'm gonna get my engineers to invent a combustible lemon that burns your house down!
User avatar
Matten
 
Posts: 435
Joined: Mon Apr 05, 2010 2:03 pm
Location: The Netherlands

Re: Need help with quick spawning

Postby REMqb » Sun Aug 15, 2010 3:42 pm

Another way:

Code: Select all
(e)=>{
    o = Scene.addBox({
        drawBorder := true;
        textureMatrix := [0.1388889, 0.0, 0.2777863, 0.0, 0.1736111, 0.5442616, 0.0, 0.0, 1.0];
        texture := "Muzzle_Flash_Side.png";
        collideSet := 0;
        zDepth := +inf;
        geomID := 10233453;
        pos := e.pos;
        angle := 0.0;
        size := [6.26, 1.75]
    });
    o.color = {[sim.time, 1.0, 1.0, 1.0]};
}


No need to use geval :) .
REMqb
 
Posts: 15
Joined: Wed Dec 30, 2009 7:51 pm
Location: France


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 4 guests