CRPL Ideas/Questions

Started by Tiuipuv, December 24, 2012, 04:44:06 PM

Previous topic - Next topic

4xC

After seeing all of this, I have to say (assuming it has not been already; I could not make out everything at once because so much space is occupied, and too many words make it hard for me too frankly) there should just be a portion on the future CW3 page that has as complete of a CPRL tower dictionary as possible when the release finally comes.

Looking at this whole thread made me also feel like I was looking into a near-infinite debate between about 100 cooks, all in different 5-star restaurants making up their own dishes, all intended to be better than their last ones even though the first one is already good enough to eat according to customer reviews and not worth actively expanding its taste detail as fast as the cooks think.

In other words, this topic is too early if you ask me.
C,C,C,C

1158511

#31
Is CRPL aware of player "economy", destructive power, and expansion? Can exponential equations be used to model creeper output? Can the emitter remove creeper? Does it support pulsing emitters, such one period of high emitting, followed by a lower form? I don't actually expect anyone to have any actually experience with the coding language, and if so this topic may be premature, however I am deeply curious, as it pertains to new idea of variable amount emitters as opposed to static amount emitters. I am looking forward toward this awesome idea, and I am excited to see what the community can make with it


Ronini

Quote from: 1158511 on January 10, 2013, 06:11:12 PM
Is CRPL aware of player "economy", destructive power, and expansion? Can exponential equations be used to model creeper output? Can the emitter remove creeper? Does it support pulsing emitters, such one period of high emitting, followed by a lower form? I don't actually expect anyone to have any actually experience with the coding language, and if so this topic may be premature, however I am deeply curious, as it pertains to new idea of variable amount emitters as opposed to static amount emitters. I am looking forward toward this awesome idea, and I am excited to see what the community can make with it


As far as I know, all of the above (except probably the exponatial equations, but my guess would be they, too) are possible with the crpl.

lurkily

Exponential equations can be done with simple  multiplication. 

If you script the crpl towers to emit in a pulsing pattern, high then low then high then low, etc, then they will.

"Set creeper" is used in the demonstration.  I presume that if you set creeper to a level lower than what is already present (such as zero) then it will, in effect, be removing creeper.

I agree that this thread is probably premature.  Wait until you can hold it in your hands and turn it around to see all sides of it.  Then a lot of what has been speculated about will be very obvious, and the ideas and flights of fancy that you can carry it to will go far beyond what you can envision right now.

Kingo

People can't help getting excited over something like this and asking questions.
For me, it's going to be the best part of CW3.

lurkily

Not enough information is out yet for people to know what questions are important. 

Not saying people shouldn't be excited.  Just that speculation at this point is to a large degree, wild and aimless.

1158511

Indeed, life may be wild and aimless, but that doesn't mean the majority of humanity isn't going to earn large degrees, or stop speculating. Perhaps it not the information that is important but the question.

"The important thing is not to stop questioning. Curiosity has its own reason for existing." -Albert Einstein

lurkily

That's my point - the right question is important.  Right now not enough is known to ask the right question.  I never said people should not speculate.

4xC

Quote from: lurkily on January 10, 2013, 09:11:48 PM
Not enough information is out yet for people to know what questions are important. 

Not saying people shouldn't be excited.  Just that speculation at this point is to a large degree, wild and aimless.

Just what I have been saying here in a nutshell.
C,C,C,C

florrat

And with the new video CRPL was brought to a whole new level making it way more epic! ;D (I had to grin when Virgil said something like "but you probably don't want to look at the code right now" just after I paused the video every second to read every piece of code he showed :) )

Ronini

Are you able to define your own functions in CRPL?

Grauniad

Quote from: Ronini on February 08, 2013, 01:16:38 AM
Are you able to define your own functions in CRPL?

If by "function" you mean "a collection of instructions/commands that can be invoked from multiple other locations", then yes.

If you mean "can I write my own new code that does something not defined by the CRPL instruction set", then no.
A goodnight to all and to all a good night - Goodnight Moon

dlbushman

Long time forum creeper, first time poster  ;D

Any chance we could get a copy of the CRPL script Virgil shows in the videos?  Mainly the more complex ones.  It does say earlier in this thread that the full CRPL API wouldn't be available, I'm assuming, until the game is released.  I've thought about going through the videos and just pausing and copying it down, but that seems tedious (unless someone has already done that :) )

I'm very much looking forward to playing CW3 and playing around with CRPL.

knucracker

#43
Welcome!

Here is a complex example. Not for the inexperienced coder...  The comments describe what it does.  This code was written using pure RPN notation (postfix notation).  CRPL also supports prefix and infix notation.  So
3 4 add        
3 add(4)        
add(3 4)        
all mean the exact same thing to the compiler.  I tend to use prefix notation a fair amount these days, but when this script was written I didn't yet support the warp operator "()" in CRPL, so it was all done in postfix.


# Patrol.crpl
# Created on: 2/2/2013 2:29:11 PM
# When attached to a unit, the unit will move around on terrain
# that is equal to the starting terrain height.  Can be used to
# create a train, or a patrolling unit that follows a 'rail' made
# out of terrain.  When the unit is faced with a choice of direction
# a random direction is chosen.  The unit also will not move back onto
# its previous location unless there is no other choice.
# ------------------------------------------

$SPEED:2

once
# Grab the current terrain height and remember this.
# We only move onto terrain that is equal to the starting height.
CurrentX CurrentY GetTerrain ->targetTerrainHeight

# Initialize our last position since we don't have one.
-1 ->lastCellX
-1 ->lastCellY

self CONST_CREATEPZ FALSE SetUnitAttribute
endonce

<-dieing if
GetTimer0 eq0 if
self 2 Destroy
endif
return
endif

#If we aren't moving, choose a new location.  The location will be a neighboring cell.
GetQueuedMoveCount eq0 if
<-base CONST_ISDESTROYED GetUnitAttribute if
true ->dieing
30 150 RandInt SetTimer0
return
endif

@ChooseNewCell if
<-chosenX <-chosenY <-SPEED QueueMove
CurrentX ->lastCellX
CurrentY ->lastCellY
endif
endif


:ChooseNewCell
-1 ->chosenX
-1 ->chosenY

# Get a list of the neighbors that we can move to.
# This call returns the coordinate pairs on the stack.
@GetPossibleCells

# Choose a random location within the list
0 <-count RandInt ->randCellNumber

# Go through the list and pop all of the coordinates off the stack
# As we pass the coordinates that we chose in our random number above, remember them.
# Those are the coordinates we will be returning.
<-count 0 do
->y
->x
I <-randCellNumber eq if
<-x ->chosenX
<-y ->chosenY
endif
loop
# Return if we chose a new location
<-chosenX -1 neq


:GetPossibleCells
#Check the four neighboring cells to see if they are the same terrain height.
0 ->count
CurrentX 1 add ->cx CurrentY ->cy @CheckCell #Right
CurrentX ->cx CurrentY 1 sub ->cy @CheckCell #Up
CurrentX 1 sub ->cx CurrentY ->cy @CheckCell #Left
CurrentX ->cx CurrentY 1 add ->cy @CheckCell #Down

# By default, we won't return the last cell coordinates.  This is so the patrolling unit
# doesn't return back to where it came from immediately.  But, if the only choice is to return
# to the previous cell, then that is what we have to do.
<-count eq0 if
<-lastCellX
<-lastCellY
1 ->count
endif


:CheckCell
#Check to see if the cell we are looking at is the last cell, if so ignore.
<-cx <-lastCellX neq <-cy <-lastCellY neq or if
# Check if the target cell is at our target terrain height.  If so, push the
# coordinates to the stack and increment count.
<-cx <-cy GetTerrain <-targetTerrainHeight eq if
<-cx
<-cy
<-count 1 add ->count
endif
endif


:destroyed
<-base neq0 if
<-base "Base.crpl" "patrolCount" GetScriptVar ->patrolCount
<-patrolCount 1 sub ->patrolCount
<-base "Base.crpl" "patrolCount" <-patrolCount SetScriptVar
endif

JH

Wait, isn't that the same code used for those moving machines in your Aether video?