Staredit Network > Forums > SC1 Mapping Tools > Topic: ProTRG v1.1
ProTRG v1.1
Jan 10 2010, 11:13 pm
By: poiuy_qwert
Pages: < 1 2 3 4 5 >
 

May 11 2010, 8:25 pm poiuy_qwert Post #61

PyMS and ProTRG developer

Quote from xAngelSpiritx
The link is dead.
(btw, what happened to bwai?)
Both should be back online now.




Jun 11 2010, 3:16 am poiuy_qwert Post #62

PyMS and ProTRG developer

You can do that with tuples:
Code
players = (1,2,3)
Trigger(*players)


Thanks for your effort yoonkwun, but could you please take down the attachment? If anyone wants to have the Memory condition all they have to do is copy the code and put it in their script or another script and import it, or they can bug me to put out an official update. No offence to you, but I have my reasons.




Jun 11 2010, 8:18 pm Cinolt Post #63



Sorry for any trouble.

For future reference, this line in ProTRG.py:
class Memory(Condition):
"""Never."""
id = 23
definition = [(LONG,2),(COMPARISON,4),(LONG,2)]

makes it so the first parameter always equals the third. I'm assuming it should be:
definition = [(LONG,1),(COMPARISON,4),(LONG,2)]




None.

Jun 11 2010, 10:59 pm poiuy_qwert Post #64

PyMS and ProTRG developer

No problem at all, thanks for taking it down! The fix you showed is correct for the problem you had, but to make the whole trigger 100% correct use:
Code
class Memory(Condition):
    """Memory at offset LONG(1) is COMPARISON LONG(2)."""
    id = 22
    definition = [(LONG,1),(COMPARISON,4),(LONG,2)]

    def TRIG(self):
        print "Memory conditions can't be compiled to .trg's in this version, they will be replaced with an Always()"
        return struct.pack('<15xB4x', 22)


Thanks again for your support!




Jun 17 2010, 8:20 pm Darknessmanlol Post #65



Ok, this stuff isnt working, and its hard enough to hold in the colorful language I want to say right now. It wont Flipping work right. I did what the program told me to do in Installation, HOWEVER, I get Trapped HERE--

If this is the first user defined language you are adding (or you just downloaded Notepad++), copy/paste the entire second file (from ProTRG) into the first, replacing all that was there. If this is the second or more language you add, simply copy everything from the ProTRG file starting at <UserLang...> to </UserLang> and paste it at the end of the userDefineLang.xml right before </NotepadPlus>

1: I cant find userDefineLang.xml for Notepad++ but I do find Lang.xml and Langs.Model.xml. Plus, when I try to copy/paste the entire second file from ProTRGs userDefineLang.xml, I cant edit it at all. Either It snot working for me, or the Installation Directions are F'd up. Help please ;-;



None.

Jun 18 2010, 10:09 pm CecilSunkure Post #66



I can just upload a copy of any of my files for you, if you'd like to use them. I don't have them now, but I will later on, so go ahead and reply here or pm me asking for specific ones.



None.

Jul 17 2010, 6:25 am Cinolt Post #67



Quote from Darknessmanlol
1: I cant find userDefineLang.xml for Notepad++ but I do find Lang.xml and Langs.Model.xml. Plus, when I try to copy/paste the entire second file from ProTRGs userDefineLang.xml, I cant edit it at all. Either It snot working for me, or the Installation Directions are F'd up. Help please ;-;

Go to Start->Run->%AppData%\Notepad++ and userDefineLang.xml should be located there, not in the Notepad++ installation directory.

I've been at it for a while now, but I can't seem to figure this out. This code gives an error:
Code
def uiPointer(ui):
    if ui == 0:
        return 5885096
    else:
        return 6455960 - 336*(ui-1)
       
def epdSelection(p, id, ui):
    t_ui = uiPointer(1)
    Memory(161889+id+(p-1)*12, Exactly, t_ui)

Code
Traceback (most recent call last):
 File "<string>", line 33, in <module>
 File "<string>", line 15, in epdSelection
NameError: global name 'uiPointer' is not defined


Can somebody give some insight as to why? I believe I declared uiPointer as a global function. Line 15 is the call to uiPointer in epdSelection.

Another issue is I can't seem to get the @include directive to work properly, both files are in the same directory, and I tried moving it to ProTRG's directory to no avail. It doesn't work with the original executable version. This is the error I get:
Code
Traceback (most recent call last):
 File "ProTRG.py", line 1576, in <module>
 File "ProTRG.py", line 1536, in main
IndexError: list index out of range


Thanks for any help.

Post has been edited 2 time(s), last time on Jul 17 2010, 6:31 am by yoonkwun.



None.

Jul 17 2010, 5:57 pm CecilSunkure Post #68



In epdSelection you use id as an argument, and id is a keyword in python. I'm unsure if you realized this or not, but you should use a different keyword than id (perhaps ID) if that was not intentional.

As for your code, it should be working just fine. It shouldn't matter what order you define your functions in. I think it's just a problem with ProTrg. To test it, go ahead and put that code in the python IDLE and run it, you'll see that the NameError is gone.

For the @include, why can't you use import?

Code
import filename, anotherfilename
from filename import specificitem
from filename import *




None.

Jul 17 2010, 6:39 pm poiuy_qwert Post #69

PyMS and ProTRG developer

Quote from Darknessmanlol
I cant find userDefineLang.xml for Notepad++
If yoonkwun's suggestion doesn't work then you may have to open Notepad++ first so it can generate the file. I didn't think of that, I assumed it came in the install.

Quote from name:yoonkwun
I've been at it for a while now, but I can't seem to figure this out. This code gives an error:
Code
def uiPointer(ui):
    if ui == 0:
        return 5885096
    else:
        return 6455960 - 336*(ui-1)
       
def epdSelection(p, id, ui):
    t_ui = uiPointer(1)
    Memory(161889+id+(p-1)*12, Exactly, t_ui)

Code
Traceback (most recent call last):
 File "<string>", line 33, in <module>
 File "<string>", line 15, in epdSelection
NameError: global name 'uiPointer' is not defined


Can somebody give some insight as to why? I believe I declared uiPointer as a global function. Line 15 is the call to uiPointer in epdSelection.
There may be a problem with ProTRG then (as Cecil stated). I don't see how but it globals might not be registering in ProTRG scripts. Try putting "global uIPointer" at the start of your function. If you have the source version you could try searching for "in globals(), locals()" in ProTRG.py and removing just that part of the line, that might fix it.

Quote from name:yoonkwun
Another issue is I can't seem to get the @include directive to work properly, both files are in the same directory, and I tried moving it to ProTRG's directory to no avail. It doesn't work with the original executable version. This is the error I get:
Code
Traceback (most recent call last):
 File "ProTRG.py", line 1576, in <module>
 File "ProTRG.py", line 1536, in main
IndexError: list index out of range


Thanks for any help.
Hmm, it looks like there is a problem with my error reporting. The problem is the imported file has an error in it, and ProTRG has an error when trying to tell you about it :S I'll have to look into this more.

Quote from CecilSunkure
For the @include, why can't you use import?

Code
import filename, anotherfilename
from filename import specificitem
from filename import *
Thats for importing python files with .py extensions. @include is for .protrg files.




Jul 17 2010, 6:48 pm CecilSunkure Post #70



Quote from poiuy_qwert
Quote from CecilSunkure
For the @include, why can't you use import?

Code
import filename, anotherfilename
from filename import specificitem
from filename import *
Thats for importing python files with .py extensions. @include is for .protrg files.
Oh I see. Does it work the exact same? Or are they different somehow other than managing different filetypes? If they are pretty much the same, you could just change the .protrg to .py and use include, right? Just curious.



None.

Jul 17 2010, 7:03 pm Cinolt Post #71



Adding global produced a syntax error, and removing the "in globals(), locals()" didn't work for me. If I try to include a file with just one variable declaration it still has the same error.



None.

Jul 17 2010, 7:08 pm CecilSunkure Post #72



Try just having everything within a single function for now. You could possibly create a class with class methods instead of having independent functions -that might not produce an error.



None.

Jul 18 2010, 6:03 am Cinolt Post #73



Here is a collection of ProTRG functions that facilitate the making of EUDs and DC arithmetic. Actually, I'm still in the concept stage for the DC arithmetic and it will take me significantly longer, so I'll release what I have done so far with the EUDs. It contains a function for EUD Keypresses and almost everything mentioned here.

EDIT: Added functions for DC assignment, multiplication, division, and assignment to resource. Even though multiplication and division are nowhere near as efficient as Morphling's MT scripts..
Release 3: Vast improvements.

Synopsis


Attachments:
util3.protrg
Hits: 5 Size: 25.48kb

Post has been edited 4 time(s), last time on Jul 23 2010, 10:38 pm by yoonkwun.



None.

Jul 23 2010, 2:48 am goobie Post #74



Quote from poiuy_qwert
Quote from Darknessmanlol
I cant find userDefineLang.xml for Notepad++
If yoonkwun's suggestion doesn't work then you may have to open Notepad++ first so it can generate the file. I didn't think of that, I assumed it came in the install.

Simply copy-pasting it into run->%AppData%\Notepad++ should work, if you've not done any user defined languages in your notepad++ before. I think.

Also, notepad++ doesn't come with NppExec (mine didn't at least), a plugin that allows you to compile source code from notepad. It's the one you need to use the f6 shortcut and paste this buisiness

NPP_SAVE
C:\Path\To\ProTRG\ProTRG.exe" "$(FULL_CURRENT_PATH)"
NPP_CLOSE "scmd_$(NAME_PART).txt"
NPP_OPEN "scmd_$(NAME_PART).txt"

NppExec can be found here. Simply extract it into Notepad++\plugins directory. It should place NppExec.dll directly into the plugins folder where it needs to be, and also a folder containing NppExec documentation.



There's got to be something more to life than being really, really, ridiculously good looking...

Jul 23 2010, 10:41 pm Cinolt Post #75



Anyone know how to properly do this in Python:

Code
a = [var1, var2, var3]
foo(a)

def foo(a):
 for i in range(len(a)):
   a[i] = someothergloballist[i]


without having to declare the variables out of the list? Or is this not possible?



None.

Jul 25 2010, 12:31 am poiuy_qwert Post #76

PyMS and ProTRG developer

yoonkwun, im not sure what you mean, try explaining a little more? And you can use enumerate() instead range(len(x)).




Jul 25 2010, 2:29 am Cinolt Post #77



I have a list of usable death counter units:
Code
dcList = [Unused1, Unused2, UnusedBldg_Terran1, UnusedBldg_Terran2, UnusedBldg_Zerg1, UnusedBldg_Zerg2]

I want the user to be able to initialize a list of his own differently-named variables to this list in the least amount of code possible. So, let's say he wanted 4 death counter variables, a timer, vhp, position X, and position Y. I want a function to set timer to Unused1, vhp to Unused2, etc. Something like this:
Code
userList = [timer, vhp, positionX, positionY]
initializeDC(userList)

def initializeDC(list):
 for i in enumerate(list):
   list[i] = dcList[i]

Of course, he could always do this:
Code
timer = dcList[1]
vhp = dcList[2]
positionX = dcList[3]
positionY = dcList[4]

But I thought with such a high level language like Python the way I described would be possible.



None.

Jul 25 2010, 3:31 am poiuy_qwert Post #78

PyMS and ProTRG developer

Code
availableDCs = [Unused1, Unused2, UnusedBldg_Terran1, UnusedBldg_Terran2, UnusedBldg_Zerg1, UnusedBldg_Zerg2]
def getDCs(dcs=1):
    global availableDCs
    if len(availableDCs) < dcs:
        print "No avaiable DC's left"
        raise
    if dcs == 1:
        return availableDCs.pop()
    slice = availableDCs[:dcs]
    del availableDCs[:dcs]
    return slice
timer = getDCs()
vhp, positionX, positionY = getDCs(3)

It returns an int if you ask for 1 (the default value), or a list of DC's if you ask for more.




Jul 25 2010, 6:56 am Cinolt Post #79



After playing around with it for a bit I ended up using this, it doesn't need the number of variables:

Code
for i, j in enumerate(dcList):
    try:
        timer, vhp, posX, posY = dcList[:i]
        break
    except ValueError:
        pass




None.

Jul 25 2010, 2:43 pm poiuy_qwert Post #80

PyMS and ProTRG developer

That code makes no sense, especially for what you want, and will not do what you think it does. What I gave you is exactly what you want, then the user would only have to do:
Code
timer = getDCs()
vhp = getDCs()
posX = getDCs()
posY = getDCs()

or
Code
timer, vhp, posX, posY = getDCs(4)

or whatever the user wants:
Code
timer = getDCs()
.. some code ..
vhp = getDCs()
.. some code ..
posX, posY = getDCs(2)





Options
Pages: < 1 2 3 4 5 >
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:36 pm]
Zoan -- what was weird was if you give the buildings to another player the computer player keeps on building it even though it doesn'y belong to them
[11:35 pm]
Zoan -- not any unit, but I did try move buildings
[11:35 pm]
Ahli -- tried moving any unit?
[08:57 pm]
Zoan -- i just tested. you actually just cant move unfinished buildings I guess. Tried moving all players and players 9 -12, tried giving players then moving. nothing works if its unfinished, but as soon as it's finished it works.
[07:54 pm]
Zoan -- Voyager7456
Voyager7456 shouted: Zoan no
;o what else do they do?
[07:49 pm]
Voyager7456 -- Zoan
Zoan shouted: so like disable all buildings but two. I mean what else is the computer player gonna do, won't they necessarily just buiild whatever they can?
no
[05:43 pm]
Zoan -- idk
[05:43 pm]
Zoan -- At least you can set the hp and build time of terran buildings so that repair never actually conteracts their hp loss while on fire..
[05:42 pm]
Zoan -- also I think you can set the hp and build time of a building so that it literally will never complete it's build, iirc.
[05:41 pm]
Zoan -- maybe if they're allied to all other players, so they don't try to do something like attack with their scv I guess.
Please log in to shout.


Members Online: Ultraviolet, Roy, morrisdnorton, Oh_Man, eugenerball