linedef texture changes with USE, but not with item itself

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!)
Post Reply
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

linedef texture changes with USE, but not with item itself

Post by ImpieTwo »

I wanna see if someone has other suggestions for this problem. With Hexenmapper's generous help I've got a puzzle similar to the fire mask puzzle on the ice map of Deathkings, where you can only do X if all of the puzzle objects are in place. I got it so that when you USE on the linedef, it removes the item from your inventory, changes the texture with the common "switch pushing" sound, and runs the script that checks if the puzzle has been solved. It works perfectly...so long as I just USE the linedef like a switch.

If I try to do it by standing at the linedef and using the item from my inventory, it doesn't change the texture or produce the sound, but it DOES remove the item from my inventory and run the "check if solved" script.

I had the linedef texture set as a switch in the ANIMDEFS lump, and began to suspect maybe that was the problem. Nope. Removing its switch status makes it refuse to change the texture or play the sound at all. Granted, it plays the sound by default probably because the texture is considered a switch, so i haven't scripted it to make the sound myself; i DID script it to change the texture though.

Script for when the item is used on the first of five puzzle linedefs, tagged 51-55:

Code: Select all

script 51 (void)        // run this every time a puzzle piece is put in place
{
    timeworks++;     // increases 'timeworks' by 1
	SetLineTexture(51,SIDE_FRONT,TEXTURE_BOTTOM,"SCSWHRG1"); // changes puzzle switch texture
    ACS_Execute(103,0,0,0,0);        // runs the 'check if puzzle complete' script
}
Oh yeah, this is in Heretic: Hexen mode, not udmf.
User avatar
Enjay
 
 
Posts: 27042
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: linedef texture changes with USE, but not with item itse

Post by Enjay »

It sounds like you might want to use this line type: [wiki]UsePuzzleItem[/wiki].
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: linedef texture changes with USE, but not with item itse

Post by ImpieTwo »

I'm using that on the linedef now, that's the problem. Hexenmapper suggested giving something similar to a thing instead, but I don't see how that would really fix the issue. I'd rather leanr to make it work with a linedef, because this feels like either I'm missing something, or something is glitched.

I'm not sure what else to post, either. I could post the whole thing privately, but then you'd have to dig through allllll the code to find what's wrong.
User avatar
Enjay
 
 
Posts: 27042
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: linedef texture changes with USE, but not with item itse

Post by Enjay »

I can't check my own files right now but you could look at the first zdoom community map. It used a Hexen gear cog and texture as a puzzle item. Given that it's a Doom map, the resources may be easier to track down/isolate. However, it is a big map with a lot of stuff in it, and it's also in zdoomhexen mode, not UDMF.
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: linedef texture changes with USE, but not with item itse

Post by ImpieTwo »

Enjay wrote:I can't check my own files right now but you could look at the first zdoom community map. It used a Hexen gear cog and texture as a puzzle item. Given that it's a Doom map, the resources may be easier to track down/isolate. However, it is a big map with a lot of stuff in it, and it's also in zdoomhexen mode, not UDMF.
I'm actually using zdoom: heretic - hexen mode, so it might work for me as well.

EDIT: I'm looking at the decorate for what you're talking about in the community map, and I can barely make heads or tails of how it works. There's SO much more going on in there than what I'm trying to do.

So what I did was, I tried to have the whole thing work from a script rather than the "use puzzle item" thing, but then it ONLY works if I "use" on it, and not if i use the puzzle item.

It really seems like the way I did it the first time ought to work for both methods, and yet it doesn't.
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: linedef texture changes with USE, but not with item itse

Post by Blue Shadow »

Could you create and post a simple WAD which demonstrates the problem?
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: linedef texture changes with USE, but not with item itse

Post by ImpieTwo »

Here's the puzzle isolated from everything else.
Attachments
timetest E1M1.wad
(15.05 KiB) Downloaded 18 times
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: linedef texture changes with USE, but not with item itse

Post by Blue Shadow »

When you use the line, you're activating the line and executing its special in the process. Since the line has a texture which is set up as a switch, it'll animate and make a sound, like any other switch. When use the puzzle item from your inventory on the line, you're not doing line activation. You're just executing the UsePuzzleItem special that's set on the line.

"But wait! I have SetLineTexture calls there in the scripts. Why aren't they working?" SetLineTexture is one of many functions which takes a line ID (similar to how sectors have tags). So you need to assign your lines IDs in order for the function to work on them. Unfortunately, in Hexen format, the only way to assign IDs to lines is by using [wiki]Line_SetIdentification[/wiki] action special. Since you can't have more than one action special assigned to a line at the same time, you can't assign a line an ID and at the same time assign it an action special in Hexen format. In UDMF, you can, because ID assignment isn't done using an action special.
ImpieTwo
Posts: 912
Joined: Sun Aug 16, 2015 11:52 pm

Re: linedef texture changes with USE, but not with item itse

Post by ImpieTwo »

Blue Shadow wrote:When you use the line, you're activating the line and executing its special in the process. Since the line has a texture which is set up as a switch, it'll animate and make a sound, like any other switch. When use the puzzle item from your inventory on the line, you're not doing line activation. You're just executing the UsePuzzleItem special that's set on the line.

"But wait! I have SetLineTexture calls there in the scripts. Why aren't they working?" SetLineTexture is one of many functions which takes a line ID (similar to how sectors have tags). So you need to assign your lines IDs in order for the function to work on them. Unfortunately, in Hexen format, the only way to assign IDs to lines is by using [wiki]Line_SetIdentification[/wiki] action special. Since you can't have more than one action special assigned to a line at the same time, you can't assign a line an ID and at the same time assign it an action special in Hexen format. In UDMF, you can, because ID assignment isn't done using an action special.
So basically the only reason this isn't working is because it's Hexen format and not UDMF?
Blue Shadow
Posts: 5043
Joined: Sun Nov 14, 2010 12:59 am

Re: linedef texture changes with USE, but not with item itse

Post by Blue Shadow »

UDMF will help you assign an ID to the line as well as an action special (UsePuzzleItem, in this case), which is what you need for your setup. If you do switch to UDMF, I'd suggest getting rid of the switch definition, and doing the texture-changing from the script. Just to keep things consistent between the two ways of activation.
Post Reply

Return to “Scripting”