Levelgen Script request
I have no knowledge of levelgen
viewtopic.php?f=33&p=21002#p21002
tau = math.pi * 2
-------------------------
--copy this block of code if you want multiple swingy-chain items, modifying the center and truecenter values accordingly.
beater1 = {}
beater1["type"] = ResourceItem --capitalization is important here.
beater1["center"] = point.new(0, 0) --Just set this to be the same as the "trueCenter" below.
beater1["trueCenter"] = point.new(0, 0) --the center of the chain
beater1["length"] = 5 --how many to make + 1. (so this will do 4)
beater1["objects"] = {} --ignore this
beater1["orbitTime"] = 2500 --2500 milliseconds to make a rotation (2 and a half seconds)
beater1["x"] = 0 --these two x and y variables are added to the ["center"] variable above each time it makes an item.
beater1["y"] = 50 --a resourceItem is about this big.
beater1["orbitDirection"] = -1 -- positive for counter clockwise, negative for clockwise
--If you make multiple, they won't show up unless you add them to the beaterArray below.
--------------------------
beaterArray = {beater1} --if you want more, put them within the {} seperated by commas. {beater1, beater2}
origin = point.zero
function doBeaters(deltaTime)
for index, value in ipairs(beaterArray)
do
for dex, val in ipairs(value["objects"])
do
local t = getMachineTime() % (value["orbitTime"]) / value["orbitTime"]
local center = value["trueCenter"]
local radius = point.distanceTo(val["loc"], center)
local pos = center + point.new(math.sin((t + 1/5) * tau * value["orbitDirection"]), math.cos((t + 1/5) * tau * value["orbitDirection"])) * radius
local unitVec = point.normalize(center - pos)
val["item"]:setVel(point.new(value["orbitDirection"] * -unitVec.y, value["orbitDirection"] * unitVec.x) * tau * radius / (value["orbitTime"] / 1000))
val["item"]:setLoc(pos)
end
end
end
function onTick(deltaTime)
doBeaters(deltaTime)
end
function main()
subscribe(Event.tick)
for index, value in ipairs(beaterArray)
do
for i = 1, value["length"]
do
item = {}
item["loc"] = value["center"]
item["item"] = value["type"].new()
item["item"]:setLoc(value["center"])
levelgen:addItem(item["item"])
table.insert(value["objects"], item)
value["center"] = point.new(value["center"].x + value["x"], value["center"].y + value["y"])
end
end
Timer:scheduleRepeating(function()
beater11["orbitDirection"] = beater11["orbitDirection"] * -1
end, 10000)
end
Little_Apple wrote:DnD: the REAL bitfighter levelgen documentation
Santiago ZAP wrote:bob doesn't make new maps, he makes new gamemodes
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
Users browsing this forum: No registered users and 2 guests