As most of you know, there are no custom codepointers or anonymous functions in old ZD 2.8.1/Zandro DECORATE, which can exponentially increase the amount of code and clutter, making your project quite a lot harder to mantain.
In order to work around this, i made "fake codepointers" which are extremely easy to use, here's the base actor you should inherit from to make fake codepointers:
Code: Select all
Actor FakeCodepointer : CustomInventory
{
INVENTORY.MAXAMOUNT 1
+INVENTORY.AUTOACTIVATE
states
{
Spawn:
TNT1 A 1
Stop
}
}
Now let's make our own codepointer after placing the above actor into our mod:
Code: Select all
Actor A_SmashReady : FakeCodepointer
{
states
{
Use:
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_TakeInventory("A_SmashReady")
Stop
}
}
Now, to use it, we just use A_GiveInventory("A_SmashReady") (replace A_SmashReady with the name of your fake codepointer) as a regular action in a frame, like this:
Code: Select all
TNT1 A 0 A_GiveInventory("A_SmashReady")
Which executes the code in the "Use" label of our fake codepointer, just like a real custom function! Do note that you can't set a frame duration for the actions in your fake codepointers, because they are ignored and just set to 0.
Here's an example where this is very helpful:
Code: Select all
Idle:
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI A 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI A 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI B 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI B 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI C 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI C 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI D 1
TNT1 A 0 A_JumpIfInventory("Input_WalkLeft", 1, "WalkLeft")
TNT1 A 0 A_JumpIfInventory("Input_WalkRight", 1, "WalkRight")
TNT1 A 0 A_JumpIfInventory("Input_Jump", 1, "Jump")
MARI D 1
Loop
As you can see, the code is really long and to change ONE state label you have to go back and change EVERY SINGLE ONE OF THEM! Which can be very tedious. So here is where the fake codepointers kick in:
Code: Select all
Idle:
MARI AABBCCDD 1 A_GiveInventory("A_SmashReady") //checks button pressses
Loop
This code does the exact same as the previous one, but because we moved the code to just one fake codepointer we can use it in every line and it works just the same,
albeit in a shorter form. I don't know how to add parameters to it, sadly, but this should already be quite helpful to shorten code and make it more maintainable.