The request is what the title says. It would be incredibly useful to be able to pass strings as parameters to scripts from decorate/line specials for things like text, actor names, references to textures and things of that nature to a script.The Zombie Killer wrote:Sadly not. If ACS scripts supported strings as parameters, then it would've been possible.zrrion the insect wrote:The thing looks promising to me, but I would like to ask, is it possible to pass text/the graphic names directly from decorate to the scripts as opposed to using the language lump?
Passing strings as parameters
Moderator: GZDoom Developers
- zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Passing strings as parameters
I've wanted to make a thread for this for a while, but didn't have a good reason to until seeing this thread. relevant part:
Re: Passing strings as parameters
Did you forget Strings aren't actually strings? 
The ACS string table is not the same as every other string table (and every library has a separate table), so passing a string would require the same index value to exist between both the caller and the specific ACS table called. Remember that strings, as far as the ACSVM is concerned, are just integers, and the first string you define per library is 0.
That's not exactly the most straightforward task.

The ACS string table is not the same as every other string table (and every library has a separate table), so passing a string would require the same index value to exist between both the caller and the specific ACS table called. Remember that strings, as far as the ACSVM is concerned, are just integers, and the first string you define per library is 0.
That's not exactly the most straightforward task.
- zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: Passing strings as parameters
Yeah, I know. I assumed there's be a bit of a problem when it comes to adding things at run time to a table that can't be touched at run time.
Is it be possible to pass strings from within ACS with something like ACS_NamedExecute("Blag",0,"Also Blag",0,0) though? If the strings are present at compile, they'd be in the string table.
Is it be possible to pass strings from within ACS with something like ACS_NamedExecute("Blag",0,"Also Blag",0,0) though? If the strings are present at compile, they'd be in the string table.
Re: Passing strings as parameters
If you're inside ACS already, the problem doesn't really get a chance to manifest, and ends up working on a technicality. Remember that what you're passing is integers, so because the same table is used, the index still matches the string you passed.
But you can already sort of do that, assuming you copy the index as an integer rather than assume it's a string. Not a very future proof plan, but it does work.
But you can already sort of do that, assuming you copy the index as an integer rather than assume it's a string. Not a very future proof plan, but it does work.
- zrrion the insect
- Posts: 2432
- Joined: Thu Jun 25, 2009 1:58 pm
- Location: Time Station 1: Moon of Glendale
Re: Passing strings as parameters
Yeah. This is looking to be a more difficult thing that I had originally thought. A reference to a table outside of ACS could work, but that would almost certainly be a lot of work to implement. I'm thinking of something similar to how you can receive strings defined in LANGUAGE using l: in a few places, but instead of a predefined list of keyword : string associations, a list would be built at run time.
Re: Passing strings as parameters
Since permanent dynamic strings in ACS are a thing now, what's stopping something like this from being implemented using the same method StrParam uses for creating new strings?
Re: Passing strings as parameters
Creating strings isn't the problem (anymore). It's knowing that they need to be created which is. With a function that handles 3 to 4 vars, you'd need a way to make the strings and integers interchangeable, while still creating and sending the proper index in the first place.
It's why execute and namedexecute are two different functions already, despite both running scripts with a number. (arg0str is also not a fun read, honestly.)
It's why execute and namedexecute are two different functions already, despite both running scripts with a number. (arg0str is also not a fun read, honestly.)
Re: Passing strings as parameters
Actually, the problem is that to DECORATE, the following are exactly the same thing:
If that weren't the case, this would be pretty trivial to add specifically for ACS scripts, but it doesn't actually track what is and isn't a string when it parses it. (Please do not take this as an endorsement to write gross DECORATE with quotation marks everywhere. It is not.)
Code: Select all
A_Something(10, 20, "Blah")
Code: Select all
"A_Something" "(" 10, "20", Blah)
Re: Passing strings as parameters
Wait, so that's why I couldn't tell what was getting passed to line actions? That's... not really what I expected. 
