FAQ  •  Register  •  Login

Levelgen Script request

<<

tazinator

Posts: 351

Joined: Fri Jul 05, 2013 7:35 pm

Post Wed Nov 13, 2013 4:33 pm

Levelgen Script request

Hi, I saw a level where there was a chain of resource items swinging around. I am planning to use that in my levels.
I have no knowledge of levelgen
Play my new level! Two different teams fight over a nexus: One mainly defends while the other attacks! is fun
viewtopic.php?f=33&p=21002#p21002
<<

thread

User avatar

Posts: 36

Joined: Sun Apr 28, 2013 3:37 pm

Location: SPAAAAAACCE!!!!!

Post Mon Nov 25, 2013 4:24 pm

Re: Levelgen Script request

I made a level like that once. PM me with what you are looking for in particular and I'll see what I can do.
_
\/
*
*
*
<<

sam686

User avatar

Posts: 468

Joined: Fri Oct 15, 2010 8:53 pm

Location: United States, South Dakota

Post Tue Nov 26, 2013 10:31 am

Re: Levelgen Script request

<<

bobdaduck

User avatar

Global Moderator

Posts: 789

Joined: Thu Mar 11, 2010 1:39 pm

Location: Utah

Post Tue Nov 26, 2013 11:42 am

Re: Levelgen Script request

  Code:
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
<<

Fordcars

User avatar

Posts: 1014

Joined: Fri Apr 20, 2012 3:51 pm

Location: Some city, somewhere

Post Tue Nov 26, 2013 6:03 pm

Re: Levelgen Script request

Bobydaducky!
skybax: Why is this health pack following me?
bobdaduck: uh, it likes you.
<<

tazinator

Posts: 351

Joined: Fri Jul 05, 2013 7:35 pm

Post Wed Nov 27, 2013 2:32 am

Re: Levelgen Script request

I put it in my level and it came apart! All I did was drive into it a few times :lol:
Edit: Ooh I see, it automatically comes apart after 10 seconds. Ha!
Edit 2: searched code after figuring out, if it's so controlled, it much be on a timer. sure enuf! :)

Another question then. Can asteroid size be controlled in a spawn?
Play my new level! Two different teams fight over a nexus: One mainly defends while the other attacks! is fun
viewtopic.php?f=33&p=21002#p21002

Return to Levelgen Gallery

Who is online

Users browsing this forum: No registered users and 1 guest

cron