Scripts / [SOLVED] Broadcast #33: "lil car" game

Author
Message
Rayparadox1982
8
Years of Service
User Offline
Joined: 6th Aug 2016
Location:
Posted: 27th Jun 2018 13:57
Okay I've been following Broadcast #33: "lil car" game PART TWO Trying to get a drivable car in my game .I copied Lua code down to the T as far as can see and I've used the blue car model from one of the model packs and renamed it just car and I edited the FPE file as well but for some reason whenever I insert the Lua code nothing happens am I doing something wrong? here is the code

inCar = 0
speed = 0
maxspeed = 1000.0
turnspeed = 250
waitForKeyRelease = 0

function car_init(e)

end

function CAR_main(e)

if GetPlayerDistance(e) <150 and incar == 0 and waitForKeyRelease == 0 then
Prompt ( "Press E to Enter")
if g_keypressE == 1 then
inCar = 1
waitForKeyRelease = 1

end

end

if inCar == 1 then
TransporttoIfUsed(e)
Collisionoff(e)

if g_keypressW == 1 then
speed = speed + 10
else
speed = speed -5

end

if g_keypressA == 1 then
RotateY(e,turnspeed)
end

if g_keypressD == 1 then
RotateY(e,turnspeed)
end

if g_keypressS == 1 then
speed = speed - 10

end

if speed > maxspeed then
speed + maxspeed
end

MoveForward( e ,speed)

if g_keypressE == 1 and waitForKeyRelease == 0 then
inCar = 0
waitForKeyRelease = 1

end

if g_keypressE == 0 then
waitForKeyRelease = 0

end

end

The author of this post has marked a post as an answer.

Go to answer
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jun 2018 14:30 Edited at: 27th Jun 2018 14:33
lua is case sensitive so make sure function names match your file name - currently you have car and CAR
Quote: "function CAR_main(e)"

Quote: "function car_init(e)"

change whichever one doesn't match your file (i.e. car.lua or CAR.lua)

also you're missing a final 'end' to close the main(e) function

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Rayparadox1982
8
Years of Service
User Offline
Joined: 6th Aug 2016
Location:
Posted: 27th Jun 2018 16:20
thanks for your help,I was told that the code no longer works.. Back to the drawing board I guess
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jun 2018 20:07
This post has been marked by the post author as the answer.
can't see any reason why it wouldn't but it's possible, did you definitely put the name of the car into the ifused field?

or why not use this one by amenmoses?
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Rayparadox1982
8
Years of Service
User Offline
Joined: 6th Aug 2016
Location:
Posted: 4th Jul 2018 12:10
Wow thanks amenmoses Truck was so much better then what I was trying to do. this saved me alot of time ..
PM

Login to post a reply

Server time is: 2024-12-22 20:03:08
Your offset time is: 2024-12-22 20:03:08