You already know me, so I'll make it quick. I've noticed that the ZSCRIPT thing is alive, and since I'm little bit skilled in decorate and ACS, I wanted to learn that thing. But wow, it look superb complicated, all those classes, thinker, iterators...too much stuff too learn. And all the introductions are too bit of not explaing to me So, would anyone lend me a hand and tech me the zcsript magic? Basically, all I need to be explained is, what to do with the stuff. Like...the documentation is little bit not existent, so learning and trying anything is hard for me.
So, would anyone help me learn zcsipt on some of my code examples?
Here is a code example. It's a night vision power-up, that could be activated and then de-activated. While active, it eats another inventory item (could be ammo, also). Since decorate of inventory items does not allow loops, I used a ACS to do the rest (check is batteries are present; if yes, it starts it's job until stopped manually or until batteries are depleted). It worsk well, but since ZCSRIPT is alive, I would like to convert it to it, so I can learn the zscript, and also so the code will be better and more fluid.
decorate (the batteries are not included, because, well...they are not crucial for this):
Code: Select all
//Night-Eye Device
//==--------------------------------------------------------------------------==
//Inventory Item
//==--------------------------------------------------------------------------==
actor NightEyeDevice : CustomInventory 23048
{
//$Category "SoA/items"
//$Color 1
//$Title "Night-Eye Device"
//flags
//==--------------------------
-Solid
+invbar
+inventory.AlwaysPickup
//==--------------------------
//dimensions
//==--------------------------
radius 8
height 24
scale 0.5
//==--------------------------
//inventory conf
//==--------------------------
Tag "$T_NGHTEYE"
inventory.icon "I_NEDV"
inventory.amount 1
inventory.maxamount 2
inventory.interhubamount 2
inventory.PickupMessage "$NGHTEYEFND"
//==--------------------------
States
{
Spawn:
NEDV V -1
Stop
Use:
TNT1 A 0 A_JumpIfInventory("lanternActiveToken", 1, "turnOff")
TNT1 A 0 A_JumpIfInventory("energyCell", 1, "turnOn")
TNT1 A 0 A_Print("\c[red]NOT ENOUGH ENERGY CELLS!", 0, "smallfont")
TNT1 A 0 A_Giveinventory("NightEyeDevice", 1)
Stop
turnOn:
TNT1 A 0 A_Print("\c[green]Night-Eye Module Activated!", 0, "smallfont")
TNT1 A 0 A_Giveinventory("lanternActiveToken", 1)
TNT1 A 0 A_Giveinventory("LanternActive", 1)
TNT1 A 0 A_Giveinventory("NightEyeDevice", 1)
TNT1 A 0 ACS_NamedExecute("nightEyeDrain", 0)
Stop
turnOff:
TNT1 A 0 A_Print("\c[green]Night-Eye Module Deactivated!", 0, "smallfont")
TNT1 A 0 A_Takeinventory("PowerLantern")
TNT1 A 0 A_Takeinventory("LanternActive")
TNT1 A 0 A_Takeinventory("lanternActiveToken", 1)
TNT1 A 0 A_Giveinventory("NightEyeDevice", 1)
TNT1 A 0 ACS_NamedTerminate("nightEyeDrain", 0)
Stop
}
}
//==--------------------------------------------------------------------------==
//mechanics
//==--------------------------------------------------------------------------==
actor PowerLantern : PowerTorch //PowerLightAmp
{
powerup.Duration 0x7FFFFFFD
//inventory conf
//==--------------------------
Inventory.Icon "A_NEDV"
//==--------------------------
}
actor LanternActive : PowerupGiver
{
//flags
//==--------------------------
+INVENTORY.AUTOACTIVATE
+INVENTORY.FANCYPICKUPSOUND
//==--------------------------
//powerup conf
//==--------------------------
powerup.Duration 0x7FFFFFFD
powerup.Type "Lantern"
//==--------------------------
//inventory conf
//==--------------------------
Inventory.MaxAmount 1
Inventory.UseSound "pickups/slowmo"
//==--------------------------
States
{
Spawn:
TNT1 A 0
Stop
}
}
actor lanternActiveToken : inventory
{
Inventory.MaxAmount 1
}
//==--------------------------------------------------------------------------==
//
Code: Select all
script "nightEyeDrain" (void)
{
while(CheckActorInventory(1337, "EnergyCell") > 1)
{
TakeActorInventory(1337, "EnergyCell", 1);
Delay(70);
}
Print(s:"Energy Cells drained out!");
TakeActorInventory(1337, "PowerLantern", 1);
TakeActorInventory(1337, "LanternActive", 1);
TakeActorInventory(1337, "lanternActiveToken", 1);
Terminate;
}