PyAI

Help - Resources - Discussion
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Thu May 08, 2008 12:02 am

Yeah it worked out :) But what do you mean by "Nice bug."?
Bhodi
Posts: 21
Joined: Fri Mar 21, 2008 4:18 pm

Postby Bhodi » Thu May 08, 2008 7:25 pm

[quote name='bajadulce' post='3872' date='May 6 2008, 10:27 PM'][spoiler]

Code: Select all

# stat_txt.tbl entry 1342: Terran Expansion Custom Level<0>
TMCx(1342, 101, aiscript):

   start_town()
   transports_off()
   farms_notiming()

   build(1, CC, 150)
   wait_buildstart(1, CC)
   build(4, scv, 130)
   wait_buildstart(4, scv)

wait(300)

--test--
debug(null, test1)
--null--
debug(null2, test2)
--null2--
debug(null3, test3)
--null3--
wait(600)
goto(test)
[/spoiler] much better.[/quote]
I wanted to try this out but for some reason I get the error:
Parameter Error: Unit 'CC' was not found. line 7 build(1, CC, 150)

same for the Entropy test.
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Fri May 09, 2008 3:22 am

Since baja uses an external definition file to name his units and you don't have it, there is no way to know what the script is trying to build. To run it, just add the variable names he used to the top of the script (scv and CC), with the unitids of the units (which you can find in the unitdef.txt). Here is how you would run it:

Code: Select all

building scv = 7
building CC = 106
# ^ Add those ^

# stat_txt.tbl entry 1342: Terran Expansion Custom Level<0>
TMCx(1342, 101, aiscript):

   start_town()
   transports_off()
   farms_notiming()

   build(1, CC, 150)
   wait_buildstart(1, CC)
   build(4, scv, 130)
   wait_buildstart(4, scv)

wait(300)

--test--
debug(null, test1)
--null--
debug(null2, test2)
--null2--
debug(null3, test3)
--null3--
wait(600)
goto(test)
User avatar
Xerxes
Posts: 43
Joined: Wed Dec 24, 2008 9:38 am

Postby Xerxes » Wed Dec 24, 2008 10:05 pm

Great program!

Is there any way PYAI could detect self-referencing loops that aren't referenced by any other part of the script? It seems to miss these when it lists sections of the script that will never be run. There's also instances of multiple isolated loops that reference eachother but are never started by the main script, but I can imagine programming PYAI to sniff those out would be much more complicated than the former.
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Thu Dec 25, 2008 12:14 am

Thank you very much.

If they are not referenced by the main script then they will not be compiled into the resulting aiscript.bin, so there is no reason to give an error about it. PyAI should be giving warnings though telling you that the code in question is not used and will not be compiled when you import/save/test the code.
User avatar
Xerxes
Posts: 43
Joined: Wed Dec 24, 2008 9:38 am

Postby Xerxes » Thu Dec 25, 2008 12:30 am

It does, except in a situation like this:

[spoiler]--DEMO 0900--
wait(300)

goto(DEMO 0900)[/spoiler]

Even if the DEMO 0900 label is never referenced anywhere else in the script, PyAI misses this. If this kind of isolated loop isn't compiled in the actual aiscript.bin, that's good, but it'd also be nice if PyAI could point this out so someone can either fix or remove their isolated loop.

Now let's say we changed this isolated loop code to read as follows:

[spoiler]--DEMO 0900--
resources_jump(800, 200, DEMO 0901)
wait(300)

goto(DEMO 0900)[/spoiler]

In this instance not only do we have code that is never used, but it also points to another block of code - 0901 - somewhere (which could branch off into many more sections of the file), and potentially there could be another 40 or more headers of code in the file that all reference eachother correctly but will never be run because the loop that initiates is only referenced once by itself, and PyAI doesn't make a peep.

This could be caught simply by telling PyAI to ignore references to a header within the same header when checking for unused code. Even though it wouldn't immediately tell you that, in the second example, there's other unused chunks of code branched off the isolated loop, because it's been pointed out to the coder he can fix it or remove it. And if he removes it, the other unused labels show up the next time PyAI checks the script.

I'm running PyAI 2.0, that is the latest version right? Just making sure.
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Thu Dec 25, 2008 9:01 am

Just because the code isn't jumped to by another part of the code doesn't mean its not used, are you sure the code doesn't just flow into that part instead of jumping to it? If the code is actually not referenced and it is not giving a warning then it could be a bug. Maybe post up/pm me the script you use to exhibit this behavior, or a small example code that produces the same error?

And yeah 2.0 is the newest version.

Return to “PyMS (poiuy_qwert's complete modding suite)”

Who is online

Users browsing this forum: No registered users and 1 guest