Forum

> > CS2D > Scripts > LUA Question - Jumping
Forums overviewCS2D overview Scripts overviewLog in to reply

English LUA Question - Jumping

2 replies
To the start Previous 1 Next To the start

old LUA Question - Jumping

Mawd
User Off Offline

Quote
Is it possible to make a script that allows you to "jump"(teleport?) over 1 tile, or obstacles?
*Jump only to the direction that you are facing*

old Re: LUA Question - Jumping

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
canjump=initArray2(32,true)

addhook("say","jump")
function jump(id,cmd)
    if (cmd=="!jump" and player(id,"exists") and canjump[id]) then
        local rot = player(id,"rot")
        if rot < -90 then rot = rot + 360 end
        local angle = math.rad(math.abs( rot + 90 )) - math.pi
        local x = player(id,"x") + math.cos(angle) * 56
        local y = player(id,"y") + math.sin(angle) * 56
        local fx = player(id,"x") + math.cos(angle) * 32
        local fy = player(id,"y") + math.sin(angle) * 32
        local tfx = math.floor(fx/32)
        local tfy = math.floor(fy/32)
        local tx = math.floor(x/32)
        local ty = math.floor(y/32)
        if x > 0 and y > 0 and x < map("xsize") * 32 and y < map("ysize") * 32 and tile(tx,ty,"property")~=1 and tile(tx,ty,"property")~=2 and tile(tx,ty,"property")~=3 and tile(tx,ty,"property")~=4 and tile(tfx,tfy,"property")~=1 and tile(tfx,tfy,"property")~=2 and tile(tfx,tfy,"property")~=3 and tile(tfx,tfy,"property")~=4 then
            parse("setpos "..id.." "..x.." "..y)
            canjump[id]=false
            timer(1000,"parse","lua canjump["..id.."]=true")
        end
        return 1
    end
end
An old script made by me. I think the tabbing will be broken. Whatever.

@Lotteria
What?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview