Code
--1st line blank
help()
print("calibrating wiggle time.")
print("do not halt (spacebar) yet.")
print("scroll down")
for i=1,1 do
start=os.clock()
selection.DeselectAll()
selection.Select(1)
structure.WiggleAll(1) --Selected(10000000000)
unhalted=os.clock()-start
print(unhalted.."unhalted")
--while os.clock()<start+10 do end
end
function replace_char(pos, str, r)
return str:sub(1, pos-1) .. r .. str:sub(pos+1)
end
function replace_str(str, pos,r)
return str:sub(1, pos-1) .. r .. str:sub(pos+#r+1)
end
info=dialog.CreateDialog("show output & use clash then close this")
gameWidth=40
bambooString="bamboo|||"
while true do
dialog.Show(info)
asteroidX=7
asteroidY=1
shoots=5
timer=5
while shoots>0 do
shipY=19
string={}
asteroidYround=math.floor(asteroidY)
for y=1,shipY do
table.insert(string,"")
if asteroidYround-#bambooString<y and y<=asteroidYround then
for x=1,asteroidX do
string[y]=string[y].." "
end
--aaList:sub ( ii, ii )
seg=y-(asteroidYround-#bambooString)
--pos=#bambooString-seg+1
--print("pos"..pos)
--test=bambooString:sub(20,20)
--print(test.."tested")
if seg>#"bamboo" then string[y]=string[y].." |" else
coinflip=seg%2 --math.random(0,1)
if coinflip==0 then
string[y]=string[y].."/"
else string[y]=string[y].." " end
end
string[y]=string[y]..bambooString:sub(seg,seg) --"asteroid"
if seg<=#"bamboo" and coinflip==1 then string[y]=string[y].."\\" end
if seg>=#bambooString and not cut then string[y]=string[y].."/|" end --shoot
end
--for testI=1,0 do end
for x=#string[y]+1,gameWidth do
string[y]=string[y].." "
end
end
clash=behavior.GetClashImportance()
behavior.SetClashImportance(.5)
side=behavior.GetSidechainHBondImportance()
if timer%5==0 then
if behavior.GetWigglePower()=='a' then --a is auto
clash=clash+math.random(-10,10)/1000
behavior.SetClashImportance(math.max(0,math.min(1,clash)
)
)
side=side+math.random(-10,10)/1000
behavior.SetSidechainHBondImportance(math.max(0,math.min(3,side)
)
)
end
end
ninja=side/3*gameWidth+1 --font size
ninjastring=" +O+"--" \\-O-/"
string[#string-2]=replace_str(string[#string-2],ninja,ninjastring)--"yokai") --"ship" --"Touhou"
if timer%8>3 then
string[#string-1]=replace_str(string[#string-1],ninja," //_\\\\")
string[#string-0]=replace_str(string[#string-0],ninja," / | ")
else
string[#string-1]=replace_str(string[#string-1],ninja," //_\\\\")
string[#string-0]=replace_str(string[#string-0],ninja," | \\")
end
halted=888
speed=0.4
bambooString="bamboo|||"
if asteroidYround==shipY-1 and ninja-2<=asteroidX and asteroidX<=ninja+#"ninja" then
--#ninjastring then
speed=0 --speed/40
bambooString="bamboo|bent|||"
--string[#string-1]=replace_str(string[#string-1],ninja," //_\\o\\-<>")
--print(not cut)
if cut then
bambooString="bamboo|is|cut|||"
else
for i=1,1 do
start=os.clock()
selection.DeselectAll()
selection.Select(1)
structure.WiggleAll(1) --Selected(10000000000)
halted=os.clock()-start
--while os.clock()<start+10 do end
end
if halted<unhalted*2 then
string[#string-1]=replace_str(string[#string-1],ninja," //_\\o\\-<>") --kunai knife shovel
shoots=shoots+1
cut=true
freeze.Freeze(structure.GetCount(),true,false)--sound effect only, natural
--freeze.Unfreeze(structure.GetCount(),true,false)
--sound effect only, sounds less natural, like a beep
end
end
--note, you cannot exec. both lines like this (I think?):
--if a then b
-- c
--end
end
timer=timer+1
shoots=shoots-.01 --2 --.03
asteroidY=asteroidY+speed --.41
angle=math.atan2(asteroidY-shipY,asteroidX-ninja) --angle=arctan(y/x) --inverse tangent
distance=math.sqrt(math.pow(asteroidY-shipY,2)+math.pow(asteroidX-ninja,2)) --a^2+b^2=c^2 --hypotenuse
asteroidY=shipY+math.sin((0.9*(clash-.5)+angle))*(distance)
asteroidX=ninja+math.cos((0.9*(clash-.5)+angle))*(distance) --angle walking
table.insert(string,angle.." is angle, "..distance.." is distance, ")
table.insert(string,tostring(shoots).." shoots (Spacebar to cut), ")--..tostring(halted).."halted")
bigstring=string[1].."\n"
for y=2,#string do
bigstring=bigstring..string[y].."\n"
end
print(bigstring)
if asteroidY-#bambooString>shipY then
asteroidX=math.random(gameWidth) asteroidY=1
cut=false
end
startTime=os.clock()
while os.clock()<startTime+1/60 do end
end --starved
info=dialog.CreateDialog("starved. use output,clash,close this")
info.l=dialog.AddLabel("or Close recipe, Adjust WigglePower (for auto walk),\n restart it.")
end