new to zscript need help with detecting bind in a script
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!)
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!)
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
new to zscript need help with detecting bind in a script
im trying to make a script that detects if the bind for secondary fire is pressed it activates a function but i cant figure out how to detect it can anyone help?
Last edited by specterrev on Tue Feb 27, 2024 9:25 am, edited 2 times in total.
-
- Posts: 875
- Joined: Mon May 10, 2021 8:08 pm
- Preferred Pronouns: He/Him
- Operating System Version (Optional): EndeavorOS (basically Arch)
- Graphics Processor: Intel with Vulkan/Metal Support
- Contact:
Re: new to zscript need help with detecting bind in a script
Is this "script" a weapon? If so, use the AltFire: state label.
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
nope I'm using it in a actual script kinda as a placeholder because I couldn't figure out custom key binds for stuff and even if I did id need to figure out this anyway, so because I don't plan for weapons to have altfires I'm using it for this script
Re: new to zscript need help with detecting bind in a script
Here's an example from the GZDoom engine itself of player buttons being checked:
https://github.com/ZDoom/gzdoom/blob/eb ... r.zs#L1239
And to check a specific button you'd use (player.cmd.buttons & BT_ALTATTACK)
Other buttons here: https://zdoom.org/wiki/Player_input_buttons
And these are other cmd properties you can use: https://github.com/ZDoom/gzdoom/blob/47 ... ayer.zs#L2
https://github.com/ZDoom/gzdoom/blob/eb ... r.zs#L1239
And to check a specific button you'd use (player.cmd.buttons & BT_ALTATTACK)
Other buttons here: https://zdoom.org/wiki/Player_input_buttons
And these are other cmd properties you can use: https://github.com/ZDoom/gzdoom/blob/47 ... ayer.zs#L2
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
i dont know if this is the correct way to reply but, i tried using "(player.cmd.buttons & BT_ALTATTACK)" in a if statement in my script and it gave me a error saying player: identifier has not been declared.7Soul wrote: ↑Mon Feb 26, 2024 3:39 pm Here's an example from the GZDoom engine itself of player buttons being checked:
https://github.com/ZDoom/gzdoom/blob/eb ... r.zs#L1239
And to check a specific button you'd use (player.cmd.buttons & BT_ALTATTACK)
Other buttons here: https://zdoom.org/wiki/Player_input_buttons
And these are other cmd properties you can use: https://github.com/ZDoom/gzdoom/blob/47 ... ayer.zs#L2
Re: new to zscript need help with detecting bind in a script
You need a player pawn variable, but it depends where you're using this script. If it's a weapon you can create one with
let player = Invoker.owner;
And I think in other cases you can do
let player = players[consoleplayer].mo; (assuming it's a single player mod)
You can learn more here: https://github.com/jekyllgrim/ZScript_B ... ata-access
let player = Invoker.owner;
And I think in other cases you can do
let player = players[consoleplayer].mo; (assuming it's a single player mod)
You can learn more here: https://github.com/jekyllgrim/ZScript_B ... ata-access
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
when I try to use the code your telling me to use it just says player not defined or players not defined, so is there anything I have to add to my wad or change with my wad to get what your telling me to use to work? because my script is just a basic standard script in my wad I haven't really messed around with adding anything because I'm new to scripting with acs and coding as a whole.7Soul wrote: ↑Mon Feb 26, 2024 6:08 pm You need a player pawn variable, but it depends where you're using this script. If it's a weapon you can create one with
let player = Invoker.owner;
And I think in other cases you can do
let player = players[consoleplayer].mo; (assuming it's a single player mod)
You can learn more here: https://github.com/jekyllgrim/ZScript_B ... ata-access
Re: new to zscript need help with detecting bind in a script
You said you were using ZScript, not ACS so I posted the solution for ZScript
I'm not super familiar with ACS but this seems to be what you're looking for: https://zdoom.org/wiki/GetPlayerInput
I'm not super familiar with ACS but this seems to be what you're looking for: https://zdoom.org/wiki/GetPlayerInput
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
sorry for not being clearer i got the two confused, also i have tried getplayerinput and it just wouldnt work for me7Soul wrote: ↑Tue Feb 27, 2024 6:59 am You said you were using ZScript, not ACS so I posted the solution for ZScript
I'm not super familiar with ACS but this seems to be what you're looking for: https://zdoom.org/wiki/GetPlayerInput
Re: new to zscript need help with detecting bind in a script
Please show your code so we can see what you did.
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
Then try this:
Code: Select all
#library "mymod"
#include "zcommon.acs"
Script "GetAltfire" ENTER
{
While(true)
{
int buttons = GetPlayerInput(-1,MODINPUT_BUTTONS);
If(buttons & BT_ALTATTACK)
{
//Your code here
}
Delay(1);
}
}
- specterrev
- Posts: 7
- Joined: Sun Feb 25, 2024 11:59 am
- Preferred Pronouns: He/Him
Re: new to zscript need help with detecting bind in a script
thanks that worked.Jarewill wrote: ↑Tue Feb 27, 2024 9:16 am Then try this:Code: Select all
#library "mymod" #include "zcommon.acs" Script "GetAltfire" ENTER { While(true) { int buttons = GetPlayerInput(-1,MODINPUT_BUTTONS); If(buttons & BT_ALTATTACK) { //Your code here } Delay(1); } }