Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Hm, I can't figure out how to add numbers to my fake inventory, I got an experimental zombieman setup where there is a chance that he will drop a dollar bundle, I forget how to make it so the player can pick it up, and have a random amount given to the inventory, any thoughts?
Actor Money : CustomInventory 10999
{
+COUNTITEM
+INVENTORY.INVBAR
+INVENTORY.HUBPOWER
Tag "$TAG_CASH"
States
{
Spawn:
MONY A -1
Stop
Pickup:
TNT1 A 0 A_GiveInventory ("Wallet", 2)
stop
}
}
In game the player is able to pick up the money atleast =)
Also, on a slight sidenote: I don't really get scripts which I will need in order to display the amount of money collected, I got zcommon.acs which includes "#include "Script.acs""
// My first ACS script
#include "zcommon.acs"
script 1 ENTER
{
print (s:"Hello world!");
}
In order to test if I can get it to display, however ingame I don't get any message?
P.S: I must have done something really stupid, as I get compilation errors with zcommon.acs
I'll include what I've done here: https://upload1.easyupload.io/uhudb9
There's CheckInventory and GetMaxInventory you can use.
Also it's recommended to use HudMessages instead of printing it, as HudMessage doesn't override things like "no key" messages and such, also it's more flexible.
Now, I don't think the way you have it setup will work.
You should have only 1 compiled script that includes both a library and include "zcommon.acs"
zcommon.acs should not even be a file in your wad.
This is how the script file should look like:
#library "ACSHUD"
#include "zcommon.acs"
Script "InitializeHUD" ENTER
{
SetHudSize (320,200,0); //SetHudSize will make the HudMessage scale to the specified resolution, perfect for HUDs
SetFont("SMALLFONT");
While(true) //It's required that the script will loop, otherwise it won't update the HUD
{
HudMessage(s:"Money: ", i:CheckInventory("Wallet"), s:" / ", i:GetMaxInventory(0,"Wallet")
;HUDMSG_PLAIN,100,CR_UNTRANSLATED,160.0,200.2,0);
Delay(1); //Delay will prevent termination
}
}
As for LOADACS, it should only include the script filename and nothing else:
Note: This screenshot was taken in a quickly thrown together .wad file, but it looks the same way in a .pk3 file.
Extensions don't need to be specified in LOADACS.
The error is about the function, not the money actor.
Are you using Zandronum by chance?
If so you will have to edit the HudMessage to have a static max amount instead of the function one.
What I mean is this:
Okay, thanks to you guys I almost got it working! I am pretty excited I must say. The hud message now shows, and the player can pick up the money dropped by monsters, and now that things are working better I can see that I made a blunder somewhere, and I suspect it is how the money object is made:
//The money object
Actor Money : CustomInventory 10999
{
+COUNTITEM
+INVENTORY.HUBPOWER
Tag "$TAG_CASH"
Inventory.Amount 1
Inventory.MaxAmount 999
States
{
Spawn:
MONY A -1
Stop
Use:
TNT1 A 0 A_GiveInventory ("Wallet", 2)
stop
}
}
The issue here is that the Money item doesn't go into it's Use state to give the Wallet item.
For CustomInventory items, you usually want to call functions from the Pickup state instead.
As it turns out, I wasn't paying enough attention and I had a runaway script error with the HUD, what causes a script to be branded "runaway?"
#library "ACSHUD"
#include "zcommon.acs"
Script "InitializeHUD" ENTER
{
SetHudSize (320,200,0); //SetHudSize will make the HudMessage scale to the specified resolution, perfect for HUDs
SetFont("SMALLFONT");
While(true) //It's required that the script will loop, otherwise it won't update the HUD
{
HudMessage(s:"Cash: ", i:CheckInventory("Wallet"), s:" / 999"
;HUDMSG_PLAIN,100,CR_UNTRANSLATED,160.0,200.2,0);
Delay(1); //Delay will prevent termination
}
}
Nothing seems to be wrong here.
It has a 1-tic delay, so it shouldn't be terminated as a runaway script.
Just as a question, did you compile it after changing the code?