Forum

> > CS2D > Scripts > stuck with lua train sytem
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch stuck with lua train sytem

20 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: stuck with lua train sytem

Banaan
User Off Offline

Zitieren
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).

alt Re: stuck with lua train sytem

Apache uwu
User Off Offline

Zitieren
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.

alt Re: stuck with lua train sytem

Banaan
User Off Offline

Zitieren
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

Mehr >

alt Re: stuck with lua train sytem

Lotteria
User Off Offline

Zitieren
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 ???

alt Re: stuck with lua train sytem

Banaan
User Off Offline

Zitieren
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

alt Re: stuck with lua train sytem

Apache uwu
User Off Offline

Zitieren
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

alt Re: stuck with lua train sytem

Banaan
User Off Offline

Zitieren
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.

alt Re: stuck with lua train sytem

Klin
User Off Offline

Zitieren
user kalis hat geschrieben
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
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht