How to use GetFriction?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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!)
Ear1h
Posts: 6
Joined: Fri May 26, 2023 5:34 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel (Modern GZDoom)

How to use GetFriction?

Post by Ear1h »

I decided to make an inventory that gives tips after a player dies and I decided to make a condition if he stands on a certain sector with reduced friction
Spoiler:
The friction coefficient is specified in TERRAIN
Spoiler:
But he does not fulfil the condition, what should I do?
Jarewill
 
 
Posts: 1546
Joined: Sun Jul 21, 2019 8:54 am

Re: How to use GetFriction?

Post by Jarewill »

Without specifying a pointer, you are checking the friction of the sector the item is in, but the item doesn't follow the player once picked up.
If you want to specifically check the player's current friction, use the owner pointer for both GetFriction and A_Print:

Code: Select all

if(owner && owner.GetFriction() == 0.8)
{
owner.A_Print("Sand Soul slows you down!");
}
Also for debugging purposes you can use console.printf() to print the current variable to the console: console.printf(""..owner.GetFriction());
Ear1h
Posts: 6
Joined: Fri May 26, 2023 5:34 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: Intel (Modern GZDoom)

Re: How to use GetFriction?

Post by Ear1h »

Jarewill wrote: Fri May 26, 2023 7:27 am Without specifying a pointer, you are checking the friction of the sector the item is in, but the item doesn't follow the player once picked up.
If you want to specifically check the player's current friction, use the owner pointer for both GetFriction and A_Print:

Code: Select all

if(owner && owner.GetFriction() == 0.8)
{
owner.A_Print("Sand Soul slows you down!");
}
Also for debugging purposes you can use console.printf() to print the current variable to the console: console.printf(""..owner.GetFriction());
If you use ...GetFriction() == 0.8, the code does not work properly

However, using debug, I notice that the value in TERRAIN is significantly different from that displayed in the console. Instead of 0.8 the console shows 0.88751

I ended up using the inequality
Spoiler:

Return to “Scripting”