Jump to content
  • 0

[ZScript] Passing a string to a script called from ZScript


Rifleman

Question

Hi everyone,

 

is it possible to pass a string to an ACS script? I have these two pieces of code and they work nicely together:
 

Spoiler

ZScript:

 


override void Tick()
	{
		super.Tick();
		FLineTraceData RemoteRay;
		double pz = height * 0.5 - floorclip + player.mo.AttackZOffset*player.crouchFactor;
		bool hit = LineTrace(
				angle,
				1000,
				pitch,
				offsetz: pz,
				data: RemoteRay
			);
		if(hit && RemoteRay.HitType == TRACE_HitActor && RemoteRay.HitActor.bISMONSTER == TRUE)
		{
			ACS_NamedExecute("EnemyHealthCheck", 0, RemoteRay.HitActor.health, RemoteRay.HitActor.SpawnHealth());
		}
		else
		{
			ACS_NamedTerminate("EnemyHealthCheck", 0);
		}
	}

 

ACS:

 


script "EnemyHealthCheck" (int currentHealth, int spawnHealth)
{
	str colour = "GREEN";
	if(currentHealth < (spawnHealth / 3) * 2)
		colour = "YELLOW";
	if(currentHealth < spawnHealth / 3)
		colour = "RED";
	SetFont("BIGFONT");
	HudMessage(d:currentHealth, s:" / ", d:spawnHealth; HUDMSG_PLAIN | HUDMSG_COLORSTRING, 0, colour, 0.5, 0.075, 0.1);
	SetFont("SMALLFONT");
	HudMessage(s:"Enemy health:"; HUDMSG_PLAIN, 1, CR_WHITE, 0.5, 0.05, 0.1);
}

 

 

But I would like to replace the 'enemy health' string with monster name, but AFAIK A_NamedExecute() only accepts integers as arguments; is there a way? Or way around it?

 

Thanks!

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 1

You make an event handler and register it in Mapinfo's Gameinfo definition. (more on https://zdoom.org/wiki/Events_and_handlers)

 

In the event handler you can override the RenderOverlay method, and from this method you can call functions of Screen, such as DrawText or DrawTexture, which... draw things like text or images on screen.

Share this post


Link to post
  • 1

I don't think there is, unfortunately.

The only way to do what you want is probably by doing everything in ZSCRIPT, which it should be easily possible, with Events

Share this post


Link to post
  • 0

Well, I dunno how to do it with events, so I would be grateful for pointers/guide/WAD to learn from. I tried playing around with ZScript Status bar but can't crack it.

 

In the meantime, I managed to partially resolve it by having the LineTrace HitActor call the script and then I use GetActorClass().

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...