![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
![]() |
#91 |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]()
Hey everyone, sorry the promised release didn't arrive.
Actually, I have all the coding changes ready, it only needs documenting the new features. Unfortunately, real life interrupted me, and I never got around to it. Let's see if I can write something tonight and release. Meanwhile, tater, it's really nice to see people actually using this in released mods ![]() |
![]() |
![]() |
![]() |
#92 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Code:
from random import randint i = group.waypoints.iterator () for waypoint in i: if waypoint.speed > 5: waypoint.speed = randint(6,10) |
|
![]() |
![]() |
![]() |
#93 |
Navy Seal
![]() Join Date: Mar 2007
Location: New Mexico, USA
Posts: 9,023
Downloads: 8
Uploads: 2
|
![]()
thx! got it!
|
![]() |
![]() |
![]() |
#94 |
Chief
![]() Join Date: Aug 2006
Location: some where in the deep blue sea
Posts: 318
Downloads: 0
Uploads: 0
|
![]()
Will This Work On Sh3 :d
|
![]() |
![]() |
![]() |
#95 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
If someone tries it, just let me know. |
|
![]() |
![]() |
![]() |
#96 |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]()
New version released at last. See first post for details.
|
![]() |
![]() |
![]() |
#97 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
found a bug using the "script" option. Injected the following code using "script" option and software displayed "error" message. used the same in the "group change" field and software worked as designed
Code:
if group.groupName.find("Merchants") != -1: i = group.units.iterator () for unit in i: if unit.type == UnitType.CARGO: i.remove () i = group.units.iterator () for unit in i: if unit.type == UnitType.TANKER: i.remove () also request a working example of the following code moveGroup(group,1000,2000) and i = mission.randomGroups.iterator () for group in i: i.insert (group.clone ()) Thabks in advance Last edited by lurker_hlb3; 06-13-07 at 08:27 PM. |
![]() |
![]() |
![]() |
#98 | ||
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Code:
i = mission.randomGroups.iterator () for group in i: [[group change code]] Code:
group_iter = mission.randomGroups.iterator () for group in group_iter: if group.groupName.find("Merchants") != -1: i = group.units.iterator () for unit in i: if unit.type == UnitType.CARGO: i.remove () i = group.units.iterator () for unit in i: if unit.type == UnitType.TANKER: i.remove () Code:
def removeShips (group, type): i = group.units.iterator () for unit in i: if unit.type == type i.remove () group_iter = mission.randomGroups.iterator () for group in group_iter: if group.groupName.find("Merchants") != -1: removeShips(group, UnitType.CARGO) removeShips(group, UnitType.TANKER) Quote:
![]() Code:
i = mission.randomGroups.iterator () for group in i: clone=group.clone() moveGroup(clone, 100000, 100000) i.add(clone) |
||
![]() |
![]() |
![]() |
#99 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
Tried this in the group change area
but gave the following error "unexpected error: java.util.ConcurrentModificationException:null Code:
i = mission.randomGroups.iterator () for group in i: clone=group.clone() moveGroup(clone, 100000, 100000) i.add(clone) |
![]() |
![]() |
![]() |
#100 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
There may be some way around it, but I'm satisfied with the current solution, since I think anyone making complex changes should be using the script mode anyway. If yuo want to find a fix, check the source (it's in src/net/sf/shbatcheditor/editor/changes/JythonRndGroupChange.java). |
|
![]() |
![]() |
![]() |
#101 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
The problem I'm having right now is that there are not any "samples" of script code.
I've made some fairly complex changes with the scripts that I created with the last version. Was able to get a lot of ideas from the "campaignchanges.py" when working with v0.3 how ever can't find the same with this version. since my last post found out that the cloning only works with "script" mode and have hacked some of my old code to work with "scripts" based on one of your other post. current problem is it doesn't like "from random import randint" call and throws out an error. Request a set of example so I can get my bearing and start using you great tool Thanks in Advance |
![]() |
![]() |
![]() |
#102 | ||
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
Quote:
Code:
# Imports at the top from random import * # Any function definitions you want to create: def removeShips (group, type): i = group.units.iterator () for unit in i: if unit.type == type i.remove ()def removeShips (group, type): # Loop over the groups i = mission.randomGroups.iterator () for group in i: # What used to be in the "group change" box, except for imports, goes here, # with the proper indentation removeShips(group, UnitType.CARGO) clone=group.clone() moveGroup(clone, 100000, 100000) i.add(clone) Hope this helps. |
||
![]() |
![]() |
![]() |
#103 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
Thanks for your help, based on your last post was able to get one of my key scripts to now work in "script" mode.
PS Hate the "White Space" rules, got so many "snytax" errors I though I was going put my fist through the monitor |
![]() |
![]() |
![]() |
#104 | |
Loader
![]() Join Date: Apr 2005
Location: Madrid, Spain
Posts: 86
Downloads: 0
Uploads: 0
|
![]() Quote:
![]() And I know whitespace control can be frustrating. But so can be figuring out why the following C/C++/Java/C# code also increments negative numbers (trivial example follows): Code:
if ( x > 0) x = x * 2; x = x + 1; ![]() |
|
![]() |
![]() |
![]() |
#105 |
Admiral
![]() Join Date: Apr 2005
Location: San Diego Calif
Posts: 2,290
Downloads: 187
Uploads: 12
|
![]()
Using "EditPad Pro" now vice "EditPad Lite", change out the other 5 scripts in about 10 minutes
Thanks again for the help Last edited by lurker_hlb3; 06-14-07 at 07:42 PM. |
![]() |
![]() |
![]() |
|
|