Flipping with PRPL

Started by GameGlitch, October 21, 2016, 12:34:34 PM

Previous topic - Next topic

GameGlitch

Hey guys,

I'm new to the Creeper World series and I know very little about coding. I don't learn very well by reading FAQs, but I learn better with a starting point and reverse engineering from there (if you can phrase it that way).

In that case then, if you don't mind the questions of an absolute newb, is it possible to flip structures using PRPL? If so, what coding is necessary to do so?

Oblivion

There is a way to flip structures in the map editor. Its prebuilt in, as for flipping when something instead of a lathe causes it. I don't know the code for it. All the map maker labeled people apparently have access to all the codes.
~Memes have been scientifrically proven to be the very essence of life unto itself~

planetfall

If you have the unit stored in the variable uid, you can flip it like this:

<-uid.UnitIsEnemy not ->uid.UnitIsEnemy

Here's an example "on-the-napkin" script to make something flippable by lathe:


once
CurrentCoords 0 1 GetAllUnitsInRange ->units
<-units GetListCount 0 do
  <-units[I] ->uid
  <-uid Self neq if
   break
  endif
loop
--units
endonce

<-uid.UnitHealth 0.05 lt if
<-uid.UnitMaxHealth ->uid.UnitHealth
<-uid.UnitIsEnemy not ->uid.UnitIsEnemy
endif
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

GameGlitch

You know, I should have been a lot more clear with what I was asking. Thank you for responding; sorry for being unclear.

What was actually looking for was to code in for a lathable structure to cause other structures to flip. I've seen a structure lathe everything on the map before, so if that can be recreated, the structures only need to be set for "flip" as Oblivion suggested. How is that done?

Oblivion

In the map editor theres an option "Has Lathe" check it if you want the structure to be able to lathe anything in its range.
~Memes have been scientifrically proven to be the very essence of life unto itself~

Builder17

I think he means inhibitor like enemy what when lathed , flips other enemies?  :-\

GoodMorning

If you mean a Totem-like structure which flips all units under certain conditions, another napkin script:


:destroyed
CurrentCoords 0 9999 GetAllUnitsInRange ->units
<-units GetListCount 0 do
   1 ->units[I].UnitIsEnemy
loop


This should flip all units to "good".
A narrative is a lightly-marked path to another reality.

GameGlitch

Thanks for all the help. I've been fiddling with things, so I didn't even realize an object like the totem existed (that is, expressly for destroying everything on the map) until very recently. Now that I understand how it works, that changes my question.

Ideally, I'd like to be able to lathe an info cache causing every allied structure except Omnis to flip to the enemy side. Basically, there's a story idea behind it, and it would be really cool to be able to do. It it possible to script something like that?






GoodMorning

Yes. Adapting the above code, you would need to have a Core which is invisible and indestructible (manual setting is easiest).

Then the script needs to find the info cache UID, and when it is destroyed, run a modified form of that code. When I have time, I'll write one for you if you need.
A narrative is a lightly-marked path to another reality.

GameGlitch

Yeah, when you get the chance, would you write it up? That would be greatly appreciated.

If I'm following right, the PRPL Core function is defined by the script that it holds/uses. As an indestructible object, the script won't be affect by being lathed. As invisible, it can't be seen, but can it still be lathed?

GoodMorning

Here's a summary:
A PRPL core is a generic "unit", which you can attach scripts to. This allows it to have more function than a brick (or not, as you choose).

Like most units, you can check boxes for "lathable", "map goal", &c.

You can also set the image for the Core.

Assuming that there are no other units in on top of the cache, and you place the Core on top of it:


once
  CurrentCoords 0 1 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] ->uid
    <-uid Self neq if
      break
    endif
  loop
  --units
  <-uid ->Cache
  --uid
endonce

<-Cache.UnitIsDestroyed if
  Self 0 DestroyUnit #This has no further use when the cache is finished with.
endif

:destroyed
  CurrentCoords 0 9999 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] GetUnitType "OMNI" neq if #Spare the Omnis, better hope you brought an "Omni Reactors" upgrade to the table.
      1 ->units[I].UnitIsEnemy #Made a mistake before, this will make them "enemy"...
    endif
loop


This may not work correctly with regard to player ships, and I've likely mangled at least one of the functions (the docs are still mostly unstarted). However, it should give you the structure of what needs to be done. If you are comfortable with looking up the cache UID then you can use "123456 ->Cache" instead of the "once" block, where you replace "123456" with whatever the UID actually is.
A narrative is a lightly-marked path to another reality.

GameGlitch

So, I tried to input the script, but I did get an error. It reads as follows: "Line: 23: A dot is only allowed in string literals and floating point numbers: .UnitisEnemy"

Oblivion

is the I capitalized? if it is
<-units(Box with I in it) ->Unit
1 ->Unit.UnitIsEnemy
might work
~Memes have been scientifrically proven to be the very essence of life unto itself~

GameGlitch

Oblivion, I get an error bouncing back. "Line 23: An 'endif' is missing a matching 'if'"

Also, I would like to point out in my previous post that I said the error was for Line 23. The error concerning ".UnitIsEnemy." is actually on line 22. My apologies if that caused any confusion. Any ideas on why it's getting stuck?

Additionally, I would like to admit that it's possible I'm doing something wrong. For approximately two days (on and off), I thought I had attached the script to the PRPL core, but, uh, nope. Only a few few minutes ago did I realize my oversight. In any case, I'm slowly understanding how this all works, but I do really appreciate all the help.

Oblivion


      <-units[I] ->Unit
1 ->Unit.UnitIsEnemy


Those two lines in the area should fix it
Overall look:


  CurrentCoords 0 9999 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] GetUnitType "OMNI" neq if
      <-units[I] ->Unit
1 ->Unit.UnitIsEnemy
    endif
loop
~Memes have been scientifrically proven to be the very essence of life unto itself~