Forum

> > CS2D > Scripts > stuck with lua train sytem
Forums overviewCS2D overview Scripts overviewLog in to reply

English stuck with lua train sytem

20 replies
Page
To the start Previous 1 2 Next To the start

old Re: stuck with lua train sytem

Banaan
User Off Offline

Quote
Factis699 do you even know the difference between a hook and a function?

We use hooks to connect functions to certain events in the game. If that event occurs, the connected function will be called. Hooks are passive, they cannot change the way the game runs.

So no, there is no 'hook like GO RIGHT GO LEFT', because that's the job of a function.

And it's certainly possible, you should use cs2d lua cmd imagepos and cs2d cmd setpos to move respectively the train and the player. Or maybe cs2d lua cmd tween_move (I've never worked with that though).

old Re: stuck with lua train sytem

Apache uwu
User Off Offline

Quote
Yeah lol it's possble--you even see a video proving it...

Tween_move in this case is more effective and will actually have a smoother animation since it's kinda like client sided lua.

old Re: stuck with lua train sytem

Banaan
User Off Offline

Quote
Yet you'll still have to move the player the same way we used to move images...

Anyway, I wrote something that might help you, note that it isn't anywhere near a functional script, it only supports one train (though with a little modification you can add more), it doesn't ride (though the functions are there) and I haven't tested it so it probably isn't even correct. But it's something

More >

old Re: stuck with lua train sytem

Lotteria
User Off Offline

Quote
Cool thanks you so much i am try.....i am complete my map just need lua to complete it thanks you again....


Banana:but your lua ...use a command or ???

old Re: stuck with lua train sytem

Banaan
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("spawn", "SetMyCurrentPosition")
addhook("move", "AmIMovingLeft")

-- Keeps track of current x coördinate
local MyPosX

-- Set spawn x coördinate
function SetMyCurrentPosition(id) MyPosX = player(id, "x") end

-- If new x coördinate is smaller than old x, player is moving to the left
function AmIMovingLeft(id, x)
	local r = false
	if x < MyPosX then r = true end
	MyPosX = x
	return r
end

old Re: stuck with lua train sytem

Apache uwu
User Off Offline

Quote
Offtopic: LOL I like your letter O's...

Ontopic: It would be better if the function allowed to change the end destination.

Ex. move_train(ID,newx,newy)

ID-->Train ID
newx-->Image_Tween to newx
newy-->Image_Tween to newy

And potentially if you want to take it a step farther you can dd add_train() etc...I'm lazy

old Re: stuck with lua train sytem

Banaan
User Off Offline

Quote
Working on it, give me some time...

Train can move in any direction (but still only in a straight line to the next waypoint), multiple trains are possible, you can set a route through waypoints, etc.

old Re: stuck with lua train sytem

Klin
User Off Offline

Quote
user kalis has written
i think video cool ,but the train only move right and left !


Nope, that Train can move in all rights. It's a station system. The Train drives from Position A to B.
It was a day work. So it isn't very hard.

Klin
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview