|
Programming Guru
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 
|
Updated. Run from temp_call.py
See auto_character.py - def figure_path > for different path options, and the randomize option. (rand 20)
I think I fixed all the bugs too.
Edit:
I've been writing path functions to make it easier to mass program.
Update for def path_figure
def path_figure(event):
path=[]
if event[0:4]=="cust":
if event[5:]=="1":path=D,D,L,L,D,D,L,L,L,U,U,U,U
elif event[0:4]=="patt":
patha=event+" "
for a in range(4,len(event)+2):
if patha[a]==" ":
if patha[a+3]==" ":patha=patha[:a+2]+"0"+patha[a+2:]
b=(len(patha)-4)/4
for l in range(b):
r1=int(patha[6+l*4]);r2=int(patha[7+l*4]);r=10*(r1)+1*(r2)
for z in range(r+1):
a=patha[5+l*4]
if a=="D":path.append(D)
elif a=="U":path.append(U)
elif a=="L":path.append(L)
elif a=="R":path.append(R)
elif event[0:4]=="rand":
for z in range(int(event[5:])):
a=random.randrange(1,5)
if a==1:path.append(D)
elif a==2:path.append(U)
elif a==3:path.append(L)
elif a==4:path.append(R)
return path
Update for temp_call.py
from character_auto import*
#########################################################################
##############################PATH_FIGURE################################
#########################################################################
# #
#To randomize movement -------------------------------- ("rand xx") #
#---- x = Any Number of Random Steps #
# #
#To make large sequences easily ----------------------- ("patt Dx Dxx") #
#---- D = Direction [U/D/L/R] #
#---- x = 1 or 2 digit number: steps for that direction #
# #
#To call a custom made path --------------------------- ("cust x") #
#---- x = Call number for that custom path #
# #
#########################################################################
path=path_figure("patt L5 D5 U12 R14 D6")
demo_movement((
("Goblin",(200,200),(path)),
("Goblin",(400,200),(path)),
),2,10,("front","nostep"),)
I think I've finally got the whole Python thing down, I feel like a pro.  :p
I even made it so if you could input one digit, instead of 0 then the digit (8 vs 08). It then adds a 0 into the string to keep it synchronized with itself. If you look at the arguments you use for patt in path_figure, you'll see what I mean. It was tricky, but good practice.
Last edited by Sane; Apr 19th, 2005 at 9:15 PM.
|