Hello.
Here comes a hacky patch for ACC/ACS that adds goto statement and labels.
Its fully functional. I tested it and even already use in one of my mods, converted
nested if for more flat and simpler if + goto.
Patch is here: http://borg.uu3.net/patch/acc+goto.patch
Regards,
Borg
ACC goto support patch
Forum rules
The Projects forums are ONLY for YOUR PROJECTS! If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
The Projects forums are ONLY for YOUR PROJECTS! If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.
Got a cool project idea but nothing else? Put it in the project ideas thread instead!
Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.
Please read the full rules for more details.
-
- Posts: 57
- Joined: Wed Oct 06, 2021 11:23 am
Re: ACC goto support patch
times ago one man showed me how to avoid goto's :] 's like
got some lengthy script, throwed it with shovel hah, about 800 lines, but even this tech not applied in there.. i would like to have some long integers or floats.. converting floats to fixed point, ye, quite funny, but no problem :]
Code: Select all
while (something)
{
// ...
if (thing) {break;}
// ...
if (anotherThing) {break;}
// ...
break;
}
-
- Posts: 13885
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: ACC goto support patch
This would be useful if you decompile an ACS script. Otherwise, yes, you should avoid goto at all costs. A patch like this simply makes it possible to recompile decompiled ACS scripts with less problem.
-
- Posts: 56
- Joined: Sun Jun 22, 2008 12:00 am
Re: ACC goto support patch
determin1st: Oh I know how to avoid them, I just dont like to avoid them 
There is nothing wrong with gotos if they are used right.
Rachael: Avoid gotos? nah.. they are usefull... real programers arent afraid of gotos
Anyway.. look at this:
Vs this one, with looks much cleaner imo:
I think next item I will turn my eye on is to make conditional evaluation shotcuted.
This of course will be much harder to do

There is nothing wrong with gotos if they are used right.
Rachael: Avoid gotos? nah.. they are usefull... real programers arent afraid of gotos

Anyway.. look at this:
Code: Select all
if(SetActivatorToTarget(0))
{
if(ClassifyActor(0)&ACTOR_PLAYER)
{
if(CheckInventory("Credits")<30000)
GiveInventory("Credits",am);
else
am=am*2;
}
else
am=am*2;
}
else
am=am*2;
if(SpawnForced("CrCoin",x,y,z,CTID+id)<1)
terminate;
Code: Select all
if(!SetActivatorToTarget(0))
goto mul2;
if(!ClassifyActor(0)&ACTOR_PLAYER)
goto mul2;
if(CheckInventory("Credits")<30000)
{
GiveInventory("Credits",am);
goto spawn;
}
mul2:
am=am*2;
spawn:
if(SpawnForced("CrCoin",x,y,z,CTID+id)<1)
terminate;
This of course will be much harder to do

-
- Posts: 13885
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: ACC goto support patch
Borg wrote:real programers arent afraid of gotos
A real jester wears a funny hat. No true jester ever wouldn't.
-
- Posts: 56
- Joined: Sun Jun 22, 2008 12:00 am
Re: ACC goto support patch
Hah.. you definitly took all that too serious... Is emotikons broken here? or not render on your browser? 
Anyway.. This should cheer you up a bit:
http://www.textfiles.com/100/real.pgmrs
Also, I updated patch.. There was a BUG
Had to use a goto actually.. hah

Anyway.. This should cheer you up a bit:
http://www.textfiles.com/100/real.pgmrs
Also, I updated patch.. There was a BUG

Had to use a goto actually.. hah

-
- Posts: 13885
- Joined: Tue Jan 13, 2004 1:31 pm
- Preferred Pronouns: She/Her
Re: ACC goto support patch
Alright. Here we go.
The reason why goto's are bad is simply because - without very strong visual cues of jump points and conditional branching, it leads to one being less able to detect bugs with these structures. Goto is great for simple code where you don't have to remember a lot and you can pretty much keep the whole thing in your head. Otherwise, things can get messy real fast. That isn't to say there never is a use for goto - even in larger projects - there is - it's just that if you can avoid it, it's often better to.
The reason why if statements and while loops are preferred is because when you use these, then you typically know where the conditionally called code stops - provided, of course, that you do yourself a favor and use proper indentation and structure for the proceeding code blocks that follow.
Everyone at some point has found some use for a goto statement. It's just that most professional programmers acknowledge that when they are present, it's so much easier to mistake code being run under undesired conditions than if they use structured blocks.
Here's a really good write-up that raises some good points about goto:
https://www.l3harrisgeospatial.com/Lear ... be-avoided
And here's another one that generally glosses over some other good points:
https://ecomputernotes.com/what-is-c/co ... -goto-in-c
The reason why goto's are bad is simply because - without very strong visual cues of jump points and conditional branching, it leads to one being less able to detect bugs with these structures. Goto is great for simple code where you don't have to remember a lot and you can pretty much keep the whole thing in your head. Otherwise, things can get messy real fast. That isn't to say there never is a use for goto - even in larger projects - there is - it's just that if you can avoid it, it's often better to.
The reason why if statements and while loops are preferred is because when you use these, then you typically know where the conditionally called code stops - provided, of course, that you do yourself a favor and use proper indentation and structure for the proceeding code blocks that follow.
Everyone at some point has found some use for a goto statement. It's just that most professional programmers acknowledge that when they are present, it's so much easier to mistake code being run under undesired conditions than if they use structured blocks.
Here's a really good write-up that raises some good points about goto:
https://www.l3harrisgeospatial.com/Lear ... be-avoided
And here's another one that generally glosses over some other good points:
https://ecomputernotes.com/what-is-c/co ... -goto-in-c
-
- Posts: 769
- Joined: Tue Jul 15, 2003 3:37 pm
Re: ACC goto support patch
Code: Select all
if(SetActivatorToTarget(0) && ClassifyActor(0)&ACTOR_PLAYER && CheckInventory("Credits")<30000)
GiveInventory("Credits",am);
else
am=am*2;
if(SpawnForced("CrCoin",x,y,z,CTID+id)<1)
terminate;
-
- Posts: 56
- Joined: Sun Jun 22, 2008 12:00 am
Re: ACC goto support patch
In ACC logical expresions are NOT short circut.
It means.. if SetActivatorToTarget() fails, it will continue to evaluate others for wrong actor.
Here its NOT that big problem, but still, its good to know about it.
It means.. if SetActivatorToTarget() fails, it will continue to evaluate others for wrong actor.
Here its NOT that big problem, but still, its good to know about it.
-
- Posts: 825
- Joined: Sun Mar 11, 2018 4:15 pm
- Location: Venezuela
Re: ACC goto support patch
Posting in case you don't know- BCC exists and has gotos implemented. It also has short circuit evaluation (completely removing the need to use goto in this example, anyway). It also is just better than ACC and there's little reason to use ACC over it, as BCC is 100% compatible with ACC and none of the extra features are mandatory, other than short circuit evaluation (that and ACC 1.58 has nothing BCC didn't already have, other than a handful of new definitions in zcommon.acs).
https://github.com/positively-charged/bcc
I know this topic is a few months old, but I really don't wanna see someone wasting their efforts (unless this is just for fun or something) just because they might not know this has already been done.
...and every opportunity I have to spread awareness of BCC's great features is one I have to take
https://github.com/positively-charged/bcc
I know this topic is a few months old, but I really don't wanna see someone wasting their efforts (unless this is just for fun or something) just because they might not know this has already been done.
...and every opportunity I have to spread awareness of BCC's great features is one I have to take

-
- Posts: 56
- Joined: Sun Jun 22, 2008 12:00 am
Re: ACC goto support patch
Yeah, I saw your BCC. I might try to use it one day 
And yeah, I didnt go implemented short-circuit evaluation in ACC, too much effort indeed.
Im happy with goto now
Unfortunately, I dont mod much these days. My playerbase evaporated, so my motivation is uber low.
As for changing ACC, im acustomed to hacking here and there
for fun as well.
I have tons of forked projects (C mostly), a bit of disassembled games where I do binary patching to fix bugs or
improve things

And yeah, I didnt go implemented short-circuit evaluation in ACC, too much effort indeed.
Im happy with goto now

Unfortunately, I dont mod much these days. My playerbase evaporated, so my motivation is uber low.
As for changing ACC, im acustomed to hacking here and there

I have tons of forked projects (C mostly), a bit of disassembled games where I do binary patching to fix bugs or
improve things
