Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: iwishforpie2 on November 19, 2014, 03:18:16 PM

Title: Modifying an emitter
Post by: iwishforpie2 on November 19, 2014, 03:18:16 PM
What command would be that? I can't seem to find it on the wiki
Title: Re: Modifying an emitter
Post by: Aeran01 on November 19, 2014, 03:24:44 PM
What do you want to do?
Title: Re: Modifying an emitter
Post by: iwishforpie2 on November 19, 2014, 03:26:34 PM
Spawn an emitter with attributes.
Title: Re: Modifying an emitter
Post by: iwishforpie2 on November 19, 2014, 03:27:45 PM
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.


# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
CreateUnit("EMITTER" CurrentCoords)
delay 999999
endif
Title: Re: Modifying an emitter
Post by: Aeran01 on November 19, 2014, 03:33:33 PM
Quote from: iwishforpie2 on November 19, 2014, 03:27:45 PM
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
   CreateUnit("EMITTER" CurrentCoords)
   delay 999999
endif

I think is easier to make a CRPLCore with no image and with an if when you reach certain conditions in your case i think it's time the core changes the image to a Emitter with your specifications tell me exactly what you want and I'll see if i can do the script
Title: Re: Modifying an emitter
Post by: iwishforpie2 on November 19, 2014, 03:35:51 PM
Quote from: Aeran01 on November 19, 2014, 03:33:33 PM
Quote from: iwishforpie2 on November 19, 2014, 03:27:45 PM
Here's my current code i'm messing with, i'm just not sure how to make it modify an emitter when it spawns.

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
   CreateUnit("EMITTER" CurrentCoords)
   delay 999999
endif

I think is easier to make a CRPLCore with no image and with an if when you reach certain conditions in your case i think it's time the core changes the image to a Emitter with your specifications tell me exactly what you want and I'll see if i can do the script

I've figured out how to. Thanks for acknowledging and trying to help. It makes me feel more confident about myself, knowing the community is there.

Final script:


# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
CurrentCoords GetTerrain 4 lt if 1
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35)
delay 999999
endif
Title: Re: Modifying an emitter
Post by: Aeran01 on November 19, 2014, 03:39:08 PM
Congratulations =)
Title: Re: Modifying an emitter
Post by: J on November 19, 2014, 04:39:29 PM
You used 'delay 999999' in your script. If you wanted to delay the next execution of the script by 999999 frames, you put them in reverse order (should be '9999 Delay' or 'Delay 9999' then), but if you only want to execute a script once, it is better to use a 'once'-block. This way the emitter won't respawn if the player turtles for too long.
I've cleaned up the code a bit:

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
once
CurrentCoords GetTerrain 4 lt if
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35000000)
SetScriptVar(<-child 0 "productionInterval" 15)
endif
endonce
Title: Re: Modifying an emitter
Post by: iwishforpie2 on November 19, 2014, 04:54:12 PM
I've made it destroy itself so it doesn't sit there.
Title: Re: Modifying an emitter
Post by: kwinse on November 19, 2014, 07:29:00 PM
Quote from: J on November 19, 2014, 04:39:29 PM
Spoiler

# Emitter1.crpl
# Created on: 11/19/2014 2:05:28 PM
# ------------------------------------------
once
CurrentCoords GetTerrain 4 lt if
CreateUnit("EMITTER" CurrentCoords) ->child
SetScriptVar(<-child 0 "productionAmt" 35000000)
SetScriptVar(<-child 0 "productionInterval" 15)
endif
endonce
[close]
That will only run the terrain check once. If you want it to create the emitter once and not on the first time the script executes, you need to put the once block in the if block.

Destroying itself is better though if the core serves no other purpose.