Curiousity Gets the Cat (Low priority theoretical CRPL questions)

Started by Flabort, January 08, 2014, 11:55:37 PM

Previous topic - Next topic

Flabort

This is where I'm putting questions that are not important enough to put into the CRPL questions thread, but are bugging me anyways.

1) What happens when you feed a list into ShowMessageDialog? Just <-TheWholeList before the command. Does it just take the most recent 3 strings?

2) Why don't SetCreeperFlowRateRL and SetCreeperFlowRateUD have entries in the wiki? It's obvious RL and UD stand for "Right-left" and "up-down" respectively, so affect how fast it flows only horizontally or vertically, not both at once. Not tested, but curious.

3) How might one create a page that you can get by clicking a spot/unit, and choose multiple options (more than two)? And then apply effects based on that choice. Such as making a screen of non-forge-based upgrades that affect AC emitters around the map, that you can call up multiple times.
My maps: Top scores: Sugarplum, Cryz Dal, Cryz Torri, Cryz Bohz (Click fetch scores, page courtesy of kwinse)

eduran

1) The list is treated as a single item and converted into a string (looking like this: "[item1, item2, ...]"). Assuming nothing else is on the stack you will get a warning in the trace log about taking items from an empty stack and a message window that is empty. The only thing that shows is the red abort button, using the entire list as text (or at least as much of the list as fits onto the button).

3) You can use a core, attach a sprite that looks like the page you want to display and use SetScreenMode(True) on it. That will lock the core to a screen position specified by SetScreenCoords. Then you would have to constantly poll the mouse to see if the player clicks a button. Something like this:
if(GetMouseButtonDown(0))
GetMousePosition ->my ->mx
if(#check if my and mx match button 1 position)
# do whatever you want to do when button 1 is pressed
else if(#same for button 2)
# repeat for all buttons
endif endif
endif

Relli

Can you please explain SetScreenMode and SetScreenCoords? I experimented with them myself, but couldn't figure out what either of them was doing.

eduran

Using SetScreenMode(TRUE) on a CRPL core has two effects:
1) The core is no longer affected by zooming in or out. Its size always stays the same.
2) The core is no longer anchored to a map cell. Instead, its position is defined relative to the bottom left corner of the game's window. Panning the map will not change the core's position. Example:

SetScreenMode(TRUE)
SetScreenCoords(0 0)
# the core will now stay in the bottom left corner of the game window
# zooming or panning the map will not change the core's position

SetScreenCoords(ScreenWidth div(2) ScreenHeight div(2))
# same as above, but the core will always be in the center of the window


And a more elaborate example. It's taken from one of my maps (Asteroid Belt, can be found here). Basically, it creates a clickable button at the top left of the screen (screenshot in the thread linked above).


# CTSwitch.crpl
# Created on: 11/5/2013 10:51:00 AM
# ------------------------------------------

# Part of the Creeper Tunnel scripts.
# This script provides the button to toggle the creeper tunnel display.

# locations of the button images
$buttonOnImg:"Custom1_128"
$buttonOffImg:"Custom2_128"

# don't change these, they are accessed by other scripts
$status:1
$name:"switch"

once
@Setup
endonce

# find out if the player clicked the button
if(GetMouseButtonDown(0))
if(distance(GetMousePosition CurrentPixelCoords) lt(10))
# button has been clicked, toggle status and image
PlaySound("Misc14")
if(<-status)
SetImageColor(Self "main" 255 255 255 0)
SetImageColor(Self "off" 255 255 255 255)
0 ->status
else
SetImageColor(Self "main" 255 255 255 255)
SetImageColor(Self "off" 255 255 255 0)
1 ->status
endif
endif
endif

# this happens every frame to make sure the button is in the right spot in case the window is resized
SetScreenPixelCoordX(105)
SetScreenPixelCoordY(ScreenHeight sub(19))

:Setup
SetUnitAttribute(Self CONST_COUNTSFORVICTORY 0)
SetUnitAttribute(Self CONST_NULLIFIERDAMAGES 0)
SetUnitAttribute(Self CONST_TAKEMAPSPACE 0)
# set images, hide the off button image
SetImage(Self "main" <-buttonOnImg)
SetImageColor(Self "main" 255 255 255 255)
SetImage(Self "off" <-buttonOffImg)
SetImageColor(Self "off" 255 255 255 0)
# anchor button to the top left corner of the screen
SetScreenMode(true)
SetScreenPixelCoordX(105)
SetScreenPixelCoordY(ScreenHeight sub(19))
# set button text
SetText("toggle creeper tunnel display (works only while game is unpaused)")
SetTextAnchor("MiddleLeft")

:Awake
SetScreenMode(true)

:GameLoaded
SetScreenMode(true)
SetTextX(11)
SetTextY(-1)
SetTextSize(0.6)



Relli

Thank you very much, eduran. This is a huge part of the idea I had, and I thought it was currently impossible. So, thank you :D

knucracker

Btw, eduran...
That Asteroid Belt map is way awesome.

I've only now started to look through some of the maps people have made (now that I have surfaced long enough to take a breath).  Very impressive coding.  Seeing this kind of thing makes me glad I added CRPL support.  I often second guess my decision to go off the deep end and add CRPL into the game, but these kind of maps make it worthwhile.

Flabort

Another one. What does IsCreeperInRange do?
I'm guessing the notation is "X1 Y1 n1 - i1", and an example would be "CurrentCoords 15 IsCreeperInRange" lets you know if there's creeper within 15 squares of the core. However, I don't know for sure.
Also, is it capable of looking for anticreeper instead? Or creeper only over a certain amount? In which case I guess the notation would get an extra "n2" in the notation.

I might just ask a dozen questions about redlinked reference commands. Let's find another to ask about. GetDeepestCreeperCell. I'm guessing this is used in the scripting of the Bertha, for autotarget mode. Just pushes coordinators where there's the most creeper. Yes? No?

GetCameraPosition... I can't think of any reason this would be needed...?

GetUnitTransformPosition. What does Transform mean in this context? The distance in X and Y from another point?
My maps: Top scores: Sugarplum, Cryz Dal, Cryz Torri, Cryz Bohz (Click fetch scores, page courtesy of kwinse)

fractalman

GetCameraPosition: potential use:
"Dude.  Don't look at the idol. If you look at the idol you will be cursed!"
-poor schmuck moves screen to the left.
-a whole bunch of emitters suddenly spawn.   

Clean0nion

Quote from: fractalman on January 11, 2014, 08:27:46 PM
GetCameraPosition: potential use:
"Dude.  Don't look at the idol. If you look at the idol you will be cursed!"
-poor schmuck moves screen to the left.
-a whole bunch of emitters suddenly spawn.   

Now that is evil. And it reminds me of https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-ash3/556357_385199148231895_1278865765_n.jpg

Flabort

Is it possible... to add a script to a non CRPL core unit using AddScriptToUnit?
Such as you have GlobalScript1 that is attached to an invisible core.
It checks for every time you build a cannon, and when you build a new cannon, adds the CustomUpgrades1 script to that cannon.
For example.

Probably not, though.
My maps: Top scores: Sugarplum, Cryz Dal, Cryz Torri, Cryz Bohz (Click fetch scores, page courtesy of kwinse)

thepenguin

Quote from: Flabort on January 11, 2014, 10:16:43 PM
Is it possible... to add a script to a non CRPL core unit using AddScriptToUnit?
Such as you have GlobalScript1 that is attached to an invisible core.
It checks for every time you build a cannon, and when you build a new cannon, adds the CustomUpgrades1 script to that cannon.
For example.

Probably not, though.
I suggest you try it.
We have become the creeper...

Clean0nion

Quote from: Flabort on January 11, 2014, 10:16:43 PM
Is it possible... to add a script to a non CRPL core unit using AddScriptToUnit?
Such as you have GlobalScript1 that is attached to an invisible core.
It checks for every time you build a cannon, and when you build a new cannon, adds the CustomUpgrades1 script to that cannon.
For example.

Probably not, though.
No, you can't. But you can change certain CONST_s. for example, you could change its health, ammo, maxhealth, maxammo, and so on.

Flabort

Wah! We might be wrong!
According to the CreateUnit page, emitters and spore towers do at least have a script attached that the SetScriptVar command can recognize! They appear to be the same variables that you can change in the editor, but this means that besides the CONST_s, there are other things we can change!
Hope springs eternal for this plan of mine.
My maps: Top scores: Sugarplum, Cryz Dal, Cryz Torri, Cryz Bohz (Click fetch scores, page courtesy of kwinse)

Clean0nion

Quote from: Flabort on January 12, 2014, 07:29:39 PM
Wah! We might be wrong!
According to the CreateUnit page, emitters and spore towers do at least have a script attached that the SetScriptVar command can recognize! They appear to be the same variables that you can change in the editor, but this means that besides the CONST_s, there are other things we can change!
Hope springs eternal for this plan of mine.
The towers that have special effects, like emitters, spore towers, inhibitors, and exclusion zones, do have a script, and its name is 0. Not "0", but 0. FALSE might work too. Those scripts have very particular vars, only a few of which are listed on the wiki.

thepenguin

0  probably isn't a script, more like a special gateway into the unit vars.
We have become the creeper...