Help with LineTrace

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.

Help with LineTrace

Postby Viper » Mon Nov 11, 2019 3:56 pm

Is there a way to get the line number from a trace to further change or get the line's information?

Code: Select allExpand view
FLineTraceData RemoteRay;
LineTrace(angle, 64, pitch, offsetz: height-12, data: RemoteRay);

  if (RemoteRay.HitType == TRACE_HitWall)
  {
      ACS_NamedExecute("ScriptName",0,RemoteRay.HitLine.<lineID>);
  }


<lineID> = ???

Thanks in advance..
Last edited by Viper on Mon Nov 11, 2019 6:00 pm, edited 1 time in total.
Viper
Banned User
 
Joined: 08 Oct 2019

Re: Anyway to get line ID from LineTrace?

Postby Matt » Mon Nov 11, 2019 4:26 pm

Just going through the variables that are defined in the line struct...

RemoteRay.HitLine.Index() return the correct value?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Anyway to get line ID from LineTrace?

Postby Viper » Mon Nov 11, 2019 5:25 pm

It executes, but I get no printable result.

I'm going to have to use a different method anyways, but I was very happy to get an answer so quick.

Thanks.
Viper
Banned User
 
Joined: 08 Oct 2019

Re: Anyway to get line ID from LineTrace?

Postby Viper » Mon Nov 11, 2019 5:50 pm

https://zdoom.org/wiki/LineTrace#Examples

This example doesn't work, am I missing something? #define etc?

it's missing the autoactivate part..

Code: Select allExpand view
   Default
   {
      +INVENTORY.AUTOACTIVATE;
   }


It now works once, when given, then ceases working, no matter how many times you give it to yourself (commands)..

not impressed with zscript
Viper
Banned User
 
Joined: 08 Oct 2019

Re: Anyway to get line ID from LineTrace?

Postby phantombeta » Mon Nov 11, 2019 11:32 pm

Viper wrote:it's missing the autoactivate part..

Code: Select allExpand view
   Default
   {
      +INVENTORY.AUTOACTIVATE;
   }


It now works once, when given, then ceases working, no matter how many times you give it to yourself (commands)..

not impressed with zscript

A bad example in the wiki does not mean ZScript is bad. The reason you can't get it to work again is because the item never gets removed from your inventory, so something that executes only when you get it won't ever execute again. That should be easily fixable by simply changing "Fail" to "Stop".
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: phantombeta_
Github ID: Doom2fan
Operating System: Windows 10/8.1/8 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Help with LineTrace

Postby Matt » Tue Nov 12, 2019 12:10 am

When I typed that example I just assumed the user would "use" it from the console. I've added the invbar stuff to it.

The better solution if you want it to do this immediately on pickup is to change "Use:" to "Pickup:".

(An even better one is to put the script in the actor you're actually using it for, of course...)
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia


Return to Scripting

Who is online

Users browsing this forum: stainedofmind and 2 guests