Jump to content
  • 0

How do I make ACS Variables that carry over to other scripts?


Gianluco

Question

Related to the last post.

I was trying to fix the spawner "following" the player by making an ACS script that gets its coordinates in the Spawn State and another one that spawns the actual spawner in those coordinates. Problem is, I don't know how to do it.

Share this post


Link to post

5 answers to this question

Recommended Posts

  • 0

You need to declare your variables outside of a script, just in your SCRIPTS file and before the scripts that use them.

Share this post


Link to post
  • 0
1 hour ago, TheEvilGrin said:

You need to declare your variables outside of a script, just in your SCRIPTS file and before the scripts that use them.

I just found out about user variables and thought it would be easier by doing this:

ACTOR WeaponRespawner : CustomInventory
{          
  Inventory.PickupMessage " "
  Inventory.PickupSound "misc/p_pkup"
  Inventory.Maxamount 0
  -COUNTITEM
  +INVENTORY.QUIET
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  var float user_X;
  var float user_Y;
  var float user_Z;
  States
  {
  Spawn:
    MEGA A 1 
	{
	 A_SetUserVar("user_X", x);
	 A_SetUserVar("user_Y", y);
	 A_SetUserVar("user_Z", z);
	}
    Loop
  Pickup:
    TNT1 A 1 A_SpawnItemEx("WeaponSpawnerNew", user_X, user_Y, user_Z) //This is line 67 
	TNT1 A 0
	Stop
  }
}

But it says this:

 

Script warning, "AmoDoom.wad:DECORATE" line 67:
Self pointer used in ambiguous context; VM execution may abort!
Script warning, "AmoDoom.wad:DECORATE" line 67:
Self pointer used in ambiguous context; VM execution may abort!
Script warning, "AmoDoom.wad:DECORATE" line 67:
Self pointer used in ambiguous context; VM execution may abort!
Script error, "AmoDoom.wad:DECORATE" line 67:
Unsafe state call in state <unknown> which accesses user variables, reached by WeaponRespawner.Pickup.

Share this post


Link to post
  • 0

Well, I think you cannot access user variables in Pickup (or Use) states, because those states are actually not executed normally from the item's context, but "hackily" executed by CallStateChain from context of the owner (player), and it does not see the variables.

Edited by jaeden

Share this post


Link to post
  • 0
8 hours ago, jaeden said:

Well, I think you cannot access user variables in Pickup (or Use) states, because those states are actually not executed normally from the item's context, but "hackily" executed by CallStateChain from context of the owner (player), and it does not see the variables.

Is there anything I can do about it? Or do I go back to using ACS?

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...