"How do I ZScript?"
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!)
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!)
-
Nash
-

- Posts: 17515
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
Well actually, I don't want it to spawn into the world. I just want to create, uhhh "data-wise" if that makes sense.
if I do let I = Spawn("MyTestItem"), it spawns at 0, 0, 0 and I can see it with IDDT.
But I don't want it to physically spawn. I just want to fill up the array on the player with instances of MyTestItem.
if I do let I = Spawn("MyTestItem"), it spawns at 0, 0, 0 and I can see it with IDDT.
But I don't want it to physically spawn. I just want to fill up the array on the player with instances of MyTestItem.
-
AFADoomer
- Posts: 1346
- Joined: Tue Jul 15, 2003 4:18 pm
Re: "How do I ZScript?"
So it sounds like you really want an array of structs that store relevant info about your inventory items? I haven't tested trying to do that, though...Nash wrote:Well actually, I don't want it to spawn into the world. I just want to create, uhhh "data-wise" if that makes sense.
if I do let I = Spawn("MyTestItem"), it spawns at 0, 0, 0 and I can see it with IDDT.
But I don't want it to physically spawn. I just want to fill up the array on the player with instances of MyTestItem.
-
Nash
-

- Posts: 17515
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
I want an array of types, yes. The item thing was just an example, it may not be an item. It could be anything.
All I want is to create an array of custom types.
I tried doing new("MyClass") but GZDoom just crashed.
All I want is to create an array of custom types.
I tried doing new("MyClass") but GZDoom just crashed.
-
hideousdestructor
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: "How do I ZScript?"
How do you check:
1. what floor texture an actor is standing on;
2. whether it's a liquid; and/or
3. whether there's any damage tag to it?
1. what floor texture an actor is standing on;
2. whether it's a liquid; and/or
3. whether there's any damage tag to it?
-
Nash
-

- Posts: 17515
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
1. floorpic (it's a TextureID so you'll need to make a TextureID variable first to look for the specific texture first; for exact usage, just Ctrl F TextureID inside gzdoom.pk3)
2 and 3 would require terrain data exposure, I'm not sure if that's supported yet.
Code: Select all
// can use full texture path or just eg FWATER
// refer to TexMan in base.txt for more info
TextureID water = TexMan.CheckForTexture ("textures/water.png", TexMan.Type_Any);
if (floorpic == water)
{
// blah
}
-
zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: "How do I ZScript?"
I'm trying to make an action function that changes the pickup message of an inventory item (hopefully you can do this in the pickup state). I would think that redefining PickupMessage would be the way to go. Am I on track even a little bit?
Code: Select all
class CustomCustomInventory : CustomInventory//Actor
{
action void A_PickupMessage(string Message)
{
PickupMessage() = Message;
}
} -
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: "How do I ZScript?"
The way I do it is to override the PickupMessage() function. Example (hopefully it's not too hard to understand):
Code: Select all
class NCItem : CustomInventory
{
class<Inventory> wpn;
string pickupMsg;
override void PostBeginPlay ()
{
if(CheckInventory("Shotgun", 1, AAPTR_PLAYER1))
{
wpn = "SuperShotgun";
pickupMsg = "You've got the super shotgun!";
}
else
{
wpn = "Shotgun";
pickupMsg = "You've got the shotgun!";
}
}
override string PickupMessage ()
{
return pickupMsg;
}
States
{
Spawn:
SOUL ABCD 6 Bright;
Loop;
Pickup:
TNT1 A 0 A_GiveInventory(invoker.wpn);
Stop;
}
}-
hideousdestructor
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: "How do I ZScript?"
Is there any way for what I'm trying here to work, so it doesn't get *even more spaghettified* than the ACS I'm hoping to replace?Nash wrote:1. floorpic (it's a TextureID so you'll need to make a TextureID variable first to look for the specific texture first; for exact usage, just Ctrl F TextureID inside gzdoom.pk3) ...
Code: Select all
textureid lq=texman.checkfortexture(
"MFLR8_4"
||"MFLR8_2"
||"SFLR6_1"||"SFLR6_4"
||"SFLR7_1"||"SFLR7_4"
||"FWATER1"||"FWATER2"||"FWATER3"||"FWATER4"
||"BLOOD1"||"BLOOD2"||"BLOOD3"
||"SLIME1"||"SLIME2"
||"SLIME3"||"SLIME4"
||"SLIME5"||"SLIME6"
||"SLIME7"||"SLIME8"
,texman.type_any);-
Nash
-

- Posts: 17515
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: "How do I ZScript?"
I don't think you can use the || operator like that. I'd probably create an array of TextureIDs, then do a for loop checking for each of them.
Code: Select all
static const String lq[] =
{
"MFLR8_4", "MFLR8_2",
"SFLR6_1", "SFLR6_4",
"SFLR7_1", "SFLR7_4",
"FWATER1", "FWATER2", "FWATER3", "FWATER4",
"BLOOD1", "BLOOD2", "BLOOD3",
"SLIME1", "SLIME2", "SLIME3", "SLIME4",
"SLIME5", "SLIME6", "SLIME7", "SLIME8"
}
for (int i = 0; i < 21; i++)
{
TextureID tx = TexMan.CheckForTexture(lq[i], TexMan.Type_Flat);
if (tx && floorpic == tx)
{
// blah
}
}
-
Major Cooke
- Posts: 8221
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: "How do I ZScript?"
It's just PickupMessage without the ().zrrion the insect wrote:I'm trying to make an action function that changes the pickup message of an inventory item (hopefully you can do this in the pickup state). I would think that redefining PickupMessage would be the way to go. Am I on track even a little bit?Code: Select all
class CustomCustomInventory : CustomInventory//Actor { action void A_PickupMessage(string Message) { PickupMessage() = Message; } }
-
zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: "How do I ZScript?"
Well, I've got this now:
and I'm getting a "Self pointer used in ambiguous context; VM execution may abort!" in reference to "PickupMsg = Message;" what would I need to do to make this unambiguous?
Code: Select all
class CustomCustomInventory : CustomInventory
{
string PickupMsg;
override string PickupMessage()
{
return PickupMsg;
}
action void A_PickupMessage(string Message)
{
PickupMsg = Message;
}
}-
Major Cooke
- Posts: 8221
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: "How do I ZScript?"
Code: Select all
return invoker.PickupMsg;-
zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: "How do I ZScript?"
that doesn't work and makes it throw an additional error.
"let PickupMsg = Message;" gets rid of the error there, bet it doesn't do anything when I call A_PickupMessage
"let PickupMsg = Message;" gets rid of the error there, bet it doesn't do anything when I call A_PickupMessage
-
Major Cooke
- Posts: 8221
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: GZBoomer Town
Re: "How do I ZScript?"
Oh whoops, misread which line you were aiming for.
My point still stands though: you need to use invoker.
My point still stands though: you need to use invoker.
Code: Select all
invoker.PickupMsg = Message;-
zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: "How do I ZScript?"
That's the ticket! Many thanks.