1
Name:
Anonymous
2011-03-04 21:33
One recurring complaint is that nobody talks about code on /prog/. So everyone write go and write some code, any code, that does something, anything, and post it. A small explanation wouldn't go amiss either.
244
Name:
Anonymous
2011-03-21 22:37
loadUnit path
-> type:(split \/ path).rhd.asStr
-> u:("$path/unit.txt".fget |> map ?.asChr.{\Newline->\Space; x->x} |> parseST
|> map [_ a b]~>[a.asStr b.eval] |> sort by=lhd)
-> s:("$path/gfxes/".ls |> map (drop fullPrefix.len+1 ?)
|> map x~>[(split \. x.asFilename).lhd x] |> sort by=lhd
|> bmap (loadUnitFrames u."building".{ye?->1; _->5} ?))
-> !s."default" |> (_ [5++dummyGfx])
-> for [t _] in tilesets s.t.{no? -> s.t=:s."default"}
-> [@!u "type"=type "gfxes"=(bdel "default" s) "layer"=tileMasks.(u."layer")
"frame"=0 "wounds"=0]
-> u."moveMask"=:(fnd [c@_]~>u.c moveClasses|>?,1 |>map tileMasks.? |> [0@?] |> fold or)
-> !u."hp" |> (_ 1)
-> !u."size" |> (_ [1 1])
-> !u."selSize"|> (_ u."size"*32)
-> !u."sight" |> (_ 0)
-> !u."attack" |> (_ "melee")
-> for dir in (ls "$dataPrefix/units/$(u."type")/sounds/")
u."sounds".(split \/ dir |> ?.rtl.rhd) =: dir.ls
-> !u."sounds"."selected" |> (_ ["$dataPrefix/sounds/ui/click.wav"])
-> u."building".{ye?
-> u."sounds"."dead" =: "$dataPrefix/sounds/misc/wreckage/".ls}
-> [type=u @!unitTypes]