Decorate ACS string sharing

Moderator: GZDoom Developers

Post Reply
User avatar
FDARI
Posts: 1097
Joined: Tue Nov 03, 2009 9:19 am

Decorate ACS string sharing

Post by FDARI »

When trying to write relatively generic ACS scripts for mods, I frequently struggle with the inability to pass strings from decorate

My proposed solution is to extend the print and strparam functions for ACS with the ability to reference "names" (globally available strings valid throughout the lifetime of the application) by their integer indexes.

The ACS print syntax is extended with the instruction "g: ‹name index›"

Decorate is extended with a new expression that takes any string and returns the permanent index of that string. It will have one, or one will be created automatically. Definition: int strIndex (string converttoindex)

Using this you can pass arbitrary class names, variable names, states and any other kind of message to a script that expects the index of a globally stored name.

It is assumed that the name index assignment is a deterministic process. As long as the executable remains unmodified, and the same (unmodified) wads are loaded in the same order, I expect that the name indexes will also be valid when loaded from previously save games. If this is not true, then the return value from STRindex would have to be considered a short-life value that should be used and discarded immediately (ideally not allowing a single tick to pass, which mandates the use of ACS_executewithresult for instant script triggering).
Spoiler: Example purposes
Attachments
acc.zip
Modified ACC binary
(30.45 KiB) Downloaded 73 times
Fname.zip
Extremely simple test
(867 Bytes) Downloaded 64 times
fname.zip
Patches
(1.32 KiB) Downloaded 69 times
Last edited by FDARI on Wed Sep 14, 2011 5:21 am, edited 1 time in total.
User avatar
Major Cooke
Posts: 8206
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: GZBoomer Town
Contact:

Re: Decorate ACS string sharing

Post by Major Cooke »

Oh my... Holy mother of...

Testing this hot shit out ASAP!
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Decorate ACS string sharing

Post by randi »

I have decided to deny this.
  1. Names are case-insensitive. This may or may not be a problem for people using this.
  2. There is no way to do proper bookkeeping to keep track of names stored in ACS variables across savegames.
  3. Giving ACS real strings would be a better solution. Despite protestations, I can probably get it done within a day.
User avatar
Nash
 
 
Posts: 17486
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Decorate ACS string sharing

Post by Nash »

If ACS gets real strings, would that mean [wiki]StrCpy[/wiki] become obsolete?
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”