Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: pastor.healer on November 03, 2014, 08:21:45 PM

Title: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 03, 2014, 08:21:45 PM
You know I would like to get to know the code for this game, but I just don't think I want to go through the learning curve.  What would be awesome is
if more code was built into the editor.  For example, I think it would be great if we could place different emitters during game play without having to learn
the code.  Also, if we could change the terrain during map play, that would be amazing.  Can you imagine mountains changing size and elevation during the
game?  That would be a wow.   And I think it's time for more pieces.  But until then, the game works. 

And thanks both of you for the encouragement for the maps.  I also have a busy ministry and CW3 gives me some down time.  It's been a nice distraction.  Thanks
also to Virgil for the hard work over the years to make this a solid game.

So to both of you, stdout and helper, thanks for your continuing comments.  They stir me to go on. 

Blessed week to all.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 03, 2014, 08:22:46 PM
Thanks Teknotiss.  You rock!
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 03, 2014, 09:31:25 PM
Quote from: pastor.healer on November 03, 2014, 08:21:45 PMI think it would be great if we could place different emitters during game play without having to learn the code.

Unless I am misunderstanding you, this is do-able in the editor right now without any extra code.

Just place the emitter, and double click on it to change it to a different value.

Then create a second emitter, double click it, and you can have it be a different emitter (different strength and time.)

Or did I misunderstand you?

QuoteAlso, if we could change the terrain during map play, that would be amazing.  Can you imagine mountains changing size and elevation during the game?

This is pretty simple to do. If you want, make a map that you want made and send it to me, telling me the details of what you want done (where you want the elevation to change mid-game, when to change it, etc.) and I'll be glad to take a stab at it. Then I can send it back to you so you can submit it to CS if you like it. It can be a sort of miniature pass the map. :) I can pm you my email or you could post the thing somewhere on the forums here. Just offerin'. :)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 04, 2014, 01:10:34 AM
What I was implying is that I would like to be able to do what writing custom code would do without writing scripts.  For example...

Wouldn't it be more interesting if we could insert things like emitters during game play without doing any custom coding?

What about moving mountains or at least being able to add dimensions to the map during game play.  Again without writing scripts.
We used to be able to do this type of map building in CW2.  We could just insert what we wanted the map to do into variables and
the software would do the coding. 

Without being able to learn the scripting language, I am at the end of map making creativity.  I can keep adding maps that challenge
the user, but I don' t know, maybe some new game pieces would be nice.  Black holes?   Meteors?   Ship crashes?   People on exploratoin
who leave the ships to retrieve or place weapons.  Anyway, just some ideas. 

The real issue is I like to make creative maps, but feel like I am hitting the creativity wall without learning how to code in this language.  I
will probably never take the time to do that.  I'm just too busy.

Am I alone in thinking this way?

The other thing that I was thinking that might make the maps more interesting, especially for the new people is if they could click on a
button on the play menu which would cut all the creeper in half by value so that they can get through the learning curve.  Then they
could go back and play the map at full power. 

Am I rambling  :)




Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: planetfall on November 04, 2014, 06:35:41 AM
Well, there are a lot of scripts already. (Turkos Prime alone has around 50. Not that I'm bragging or anything ::)) You can always extract scripts from maps to provide the extra game pieces if you don't mind being limited to the things already created. Or, forum members will usually be glad to make requested scripts for you.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 04, 2014, 08:08:45 AM
planetfall is right that there is a lot out there already that you can draw from.

I know what you mean about not being able to take the time to learn the programming language. I'm largely the same way and as much as I'd like to, I haven't spent more than a few hours total in learning CRPL. I'll never make awesome scripts like planetfall, stewbasic, warren and others. But I can make simple little tools that enhance the game and I think you could, too.

You mentioned making emitters appear during a map. That is unbelievably easy and requires just a few lines of code. I and many others would be very glad to hear your requests and give you a script that you can add to your future map. Then all you have to do is create a CRPL core and attach the script you want to it. It's really easy.

Helm's Deep (one of my earlier maps) has a custom ally (Gandalf shows up mid game and helps destroy the enemies) but it only has like 15 total lines of code.

PH I just put together an example map for you to download and look at. Copy it to your WorldEditor/UNSET/save.cw3 and then load it up in your projects CW3. Once it's loaded, look under WorldEditor/UNSET/scripts/ and you'll see the custom emitter script. 4 lines of code total. This map creates an emitter at exactly 60 seconds into the game.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: Stave on November 04, 2014, 01:40:12 PM
Quote from: stdout on November 04, 2014, 08:08:45 AM
Helm's Deep (one of my earlier maps) has a custom ally (Gandalf shows up mid game and helps destroy the enemies) but it only has like 15 total lines of code.

Gandalf is adorable, by the way. I loved that cute little blue ball of AC just rolling through the creeper.  ;D
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 04, 2014, 06:13:30 PM
Excellent!  Thanks so much.  I will do that and look at what you have sent me.  Well, maybe this will add a new
dimension to my maps. 

I will let you know how this turns out....

Blessings
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 04, 2014, 06:53:48 PM
I can't wait!  :)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 04, 2014, 09:04:25 PM
Oh wow!  We have a new player on the horizon.... Nicely played!
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 05, 2014, 02:26:50 AM
Thanks!  I will try it  :)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 05, 2014, 11:41:58 AM
So I did what you instructed me to do but for some reason I don't see any scripts or see an emitter show up at 60 seconds.  The game plays yet I don't see any corep on the map.  I wonder what I am doing wrong?
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 05, 2014, 11:59:45 AM
The core is kind of invisible. After 60 seconds the emitter will appear in its place. Did you bring the file into the editor?
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 05, 2014, 12:09:41 PM
More info. Go into the Edit mode (where you can build the terrain and units) and you should see the crpl core show up. It is transparent in edit mode and completely invisible in playing mode.

The coords to the core are 74,12

Go to the Units menu and double click on the core to see the attached scripts window. Let me know how that goes.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: teknotiss on November 05, 2014, 02:55:02 PM
Quote from: pastor.healer on November 03, 2014, 08:21:45 PM
What would be awesome is if more code was built into the editor.  For example, I think it would be great if we could place different emitters during game play without having to learn
the code.  Also, if we could change the terrain during map play, that would be amazing.  Can you imagine mountains changing size and elevation during the
game?  That would be a wow.   And I think it's time for more pieces.  But until then, the game works. 

you and me both dude!  :'(
i did suggest adding some basic CRPL cores etc to the editor but V was rushing to finish the game at that point.
i wanted something like the fields in CW2 but much more so, imagine a user can just draw a shape freehand or with straight edges and within that area choose an effect or multiple variable timed effects. you could have (multi)directional push/pull fields, conversion effects, wave and swirly stuff, and prob others i haven't thought up!
i still live in faint hope. :(
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 05, 2014, 07:19:23 PM
stdout, so I have looked at the map you sent me and no matter what mode I am in, edit, non-edit, playing the game, I don't see any trace of the crplcore.  Forgive my ignorance in this.  It seems like it should be easy. 

When I play the game I don't see any new emitter show up either. 

The map I am seeing has five emitters, two orbital weapons and two spore towers.  Do I have the right map?

Thanks for your patience with me on this.  I am really looking forward to playing with some of this if I don't find it ridiculous in its learning curve.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 05, 2014, 09:01:21 PM
Quote from: pastor.healer on November 05, 2014, 07:19:23 PMThe map I am seeing has five emitters, two orbital weapons and two spore towers.  Do I have the right map?

Ahh, definitely not. The map I uploaded was a small map that only had one spore tower by itself and then the invisible crpl core.

I just now downloaded again the file above and used it and confirmed that the map is good. So please try downloading it again and try again. Make sure you call it "save.cw3" in the folder for your project. We'll get this working and you'll soon see how easy it is to add scripts to your games. (and then we'll have a new world of fun new maps from PH!) :)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 05, 2014, 09:19:38 PM
Ok... got it!  I don't know how the other map was showing up.  I deleted the Unset folder and copied it back there again.  Anyway, got the new file and did the same thing and it worked great. 

Now... I see three files with this game. 

CreateCircle.crpl
CreateEmitter.crpl
Wall2Terrain.crpl

My first question is why there are two others when this is a simple map?

And when I open up CreateEmitter.crpl I see one long line of code and instruction.  When I open up CreateCircle.crpl, I see single lines of code.

Will you help me to understand that?

Also, should we be doing this on a game thread?  If not, just let me know what I need to do to keep things 'legal'. 

Blessings stdout
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 05, 2014, 09:32:02 PM
I re-visited the CreateEmitter file and saw that the formating was just gone.  I moved each line down where it belongs and see the code layed out now.  Excellent!

So the only question I have now is this.  I don't see where the variables are defined. 


$rate:15

$amount:10

# 1800 is the number of frames to wait before creating the emitter.

# So in this example, the emitter will appear at 1 minute into the game.



GetGameTimeFrames 1800 gt
if
  SetImage(Self "Main" "CustomEmitter")
 
   SetUnitAttribute(Self CONST_COUNTSFORVICTORY TRUE)
 
   CurrentCoords <-amount AddCreeper <-rate Delay

endif


I assume the CurrentCoords ties to where I place a crplcore? 

I see where amount is defined above as 10 just as if I set an emitter and gave it a value
of 10

And I am guessing rate Delay is also tied to the rate above.  But why the - sign and how
do the < signs operate in this code?

Lastly is there a list of the actual assigned words used by this software with any definitions
of how they are used?

I didn't think I would play with the software but if I can learn the basics, this might be a good way to get new stuff into the games.

Again, thanks for your help.


Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: Harkler on November 05, 2014, 11:35:19 PM
A full run-down of this code:










$rate:15
$amount:10
Variables

-
GetGameTimeFrames 1800 gt      Checks to see if the time has passed 1800 frames
-
ifSkips to EndIf if above is FALSE
-
SetImage(Self "Main" "CustomEmitter")Applies the "CustomEmitter" image to the CRPL core

-
SetUnitAttribute(Self CONST_COUNTSFORVICTORY TRUE)Sets the core as a unit that must be destroyed to win the game

-
CurrentCoords <-amount AddCreeperAdds the variable "amount" creeper to the cell occupied by the unit
-
<-rate DelayDelays the game by the variable "rate" frames
-
EndIfSignifies the end of the "If" command (duh)
-

Detailed Version










$rate:15
$amount:10
These are where variables are initially defined. You can change these by double clicking on the unit, clicking on the associated script, and modifying them under Input Variables. Placing a "$" before a string at the top defines it as an input variable. (make sure to click "APPLY VALUES AND RECOMPILE" after modifying them in the editor, else they won't take effect)
-
GetGameTimeFrames 1800 gt      This line of code will compare the current game time (in frames) to the number 1800. If it is greater than 1800 (gt), it will leave the number 1 (True), if not, it will leave 0 (False) (The emitter will actually be built on the 1801st frame because "1800 1800 gt" would return 0 (False))
-
ifThis command will look at the number from above. If it is 1 (True), every line until the command "EndIf" will run (unless there is an "Else" command).
If not, It will skip every command until it reaches the "EndIf" command (or the "Else" command)
-
SetImage(Self "Main" "CustomEmitter")The 3 arguments for "SetImage" are "Unit UID", "Image Slot", and "Custom Image Names". "Self" is a command that gets its own UID, "Main" is the default image slot, "CustomEmitter" is a built-in image name along with "CustomSporeTower" and "CustomRunnerNest". All other custom images must be loaded into the game and will look like "Cusom13"
-
SetUnitAttribute(Self CONST_COUNTSFORVICTORY TRUE)The 3 arguments for "SetUnitAttribute" are "Unit UID", "Attribute Constant", and "Value". "Self" again, "CONST_COUNTSFORVICTORY" is one of many constants that can be changed (Rather ironic), TRUE returns 1 (FALSE-0)
-
CurrentCoords <-amount AddCreeper"CurrentCoords" returns the unit's X coordinate followed by the Y coordinate, "<-Amount" places the variable defined at the top, AddCreeper takes the X, Y, and # from before it and adds # creeper at X, Y to the creeper already there. (most emitters use "SetCreeperNoLower", because if you keep adding more and more creeper,  it will eventually flip to AC)
-
<-rate Delay"<-Rate" will place the variable define at the top, then "Delay" will stop the code from doing anything for "<-Rate" frames. (Code will continue after "Delay" once it is complete)
-
EndIfSignifies the end of the "If" command (duh)
-


The code will wait 1 frame after it reaches the end, then will start again from the top
The emitter will actually emit every <-Rate +1 frames due to this delay
[close]


I assume the CurrentCoords ties to where I place a crplcore?
            Yes, This represents the X & Y coordinates of the core

I see where amount is defined above as 10 just as if I set an emitter and gave it a value of 10
            Yes, and it can be changed just by double-clicking the core

And I am guessing rate Delay is also tied to the rate above.  But why the - sign and how do the < signs operate in this code?
            <-InsertWord will place the variable "InsertWord" at the top of the stack

Lastly is there a list of the actual assigned words used by this software with any definitions of how they are used?
            Right here (http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference) (then hit Ctrl-D)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: pastor.healer on November 06, 2014, 12:47:05 AM
Wow!  Thanks so much.  I will begin to look at the key words and see how this all comes together. 

Blessings to you all
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 06, 2014, 07:41:54 AM
Harkler, thank you for taking the time to explain that. :)

The CreateCircle and Wall2Terrain scripts can be ignored. I included those on accident. They are scripts I was using for the last map project I made. The only script you needed was the CreateEmitter.crpl unit.

In the CreateEmitter script, you could probably add another variable at the top for frames_past. So something like:

$frames: 1800

Then down in the code, you'd change the 1800 number to <-frames and this way you could then set the timer inside the map editor rather than editing a script. This would be helpful if you wanted to create multiple of these emitters in a single map, each with a different appearance time.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 06, 2014, 07:42:32 AM
...because variables like that can be changed on a core by core basis in the editor. You double click on the core and it shows you which variables can be changed.
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: Karsten75 on November 06, 2014, 08:25:27 AM
I suggest you guys find the origin of the off-topic discussion and let me know where you want it to be moved (Coders Corner?) - the last one million or so posts are not relevant to this particular map. :)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: stdout on November 06, 2014, 09:19:31 AM
Starting with msg123677 (Reply #9 to this thread)
Title: Re: Re: Custom Map #1314: Spiral Galacrazy. By: Pastor.Healer
Post by: DestinyAtlantis on November 06, 2014, 01:04:05 PM
Don't forget that you can edit your posts, so as to not double/triple/quadriple post.