The online racing simulator
Searching in All forums
(285 results)
Skagen
S3 licensed
Quote from Keling :Isn't socket.close() sufficient for freeing the socket? I tried this

if keyboard.getKeyDown(exitKey):
sockOS.shutdown(0)
sockOS.close()
sys.exit(0)

at the beginning of the loop but rerunning the script still fail.

I thought it would be. I actually never tried to use the close() method properly and I thought that was the reason I could not create new sockets within the Python interpreter in FreePIE.

You could ask the FreePIE guy, I'm not very familiar with neither FreePIE nor Python in general. There might be some other trick to it.
Skagen
S3 licensed
I figured that FreePIE can receive OutGauge and OutSim packets, so you can read realtime data about the car and the game into your PIE scripts. Really cool.

Simple example to monitor the car speed and gear with a none-blocking socket. Note the exception handling when there was no UDP packet available for the given loop iteration.
Another thing to note is that to my knowledge, FreePIE does not have a "stopping" bool like the "starting" bool, so you cannot properly close the socket when you stop the script. To re-run it, you need to restart FreePIE in order to free up the socket.

It can be used, for instance, to reduce the max braking power when the speed goes below a threshold to help prevent flatspotting. Or if you're really pro, you can make your PIE script be aware of oversteer and understeer in realtime. Lots of ideas springs to mind.


if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 5

import socket
import struct

global sock, outgauge
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Set the socket to be none-blocking, otherwise the
# loop will have to wait for each UDP packet to be received
sock.setblocking(0)
sock.bind(('127.0.0.1', 30000))
outgauge = None

global car_speed_unit, car_speed, car_gear
# 1 = m/s, 3.6 = km/h
car_speed_unit = 3.6
car_speed = 0
car_gear = 0

global shift_up_key, shift_down_key
shift_up_key = Key.W
shift_down_key = Key.S

# ====================================================
# LOOP START
# ====================================================

try:
outgauge = struct.unpack('I3sxH2B7f2I3f15sx15sx', sock.recv(256))
car_speed = int(round(outgauge[5] * car_speed_unit))
car_gear = int(round(outgauge[3])) - 1
except socket.error, e:
# This code prevents the car_gear to be async while waiting for a UDP packet with the real gear value
if keyboard.getKeyDown(shift_up_key) and not keyboard.getKeyDown(shift_down_key):
car_gear = car_gear + 1
elif keyboard.getKeyDown(shift_down_key) and not keyboard.getKeyDown(shift_up_key):
car_gear = car_gear - 1

diagnostics.watch(car_speed)
diagnostics.watch(car_gear)

Last edited by Skagen, .
Skagen
S3 licensed
I made the same argument 2 years ago, but back then to no prevail: https://www.lfsforum.net/showthread.php?t=80366
Skagen
S3 licensed
Gah, makes me want to get a DK2 now.
Skagen
S3 licensed
Quote from Scawen :...and we could do with the cash!

1. Give people additional options to fund the development outside just purchasing licenses.
2. More updates and openness about the development.

A.k.a the Star Citizen and Elite: Dangerous model. It seems to work, and I'm sure this community would be equally enthusiastic about helping you fund the continued development of LFS.
Skagen
S3 licensed
Here's my FreePIE + vJoy script for mouse steering. It was initially made to mimic the LFS style of mouse steering in other racing games, and the axes are therefor mapped to the axes which the default G27 profile had in the games I tested.

It isn't very elegant because I ran into scoping problems as soon as I tried to solve this using functions and classes/objects.

The script features:
  • Easy axis inversion controls
  • LFS style sensitivity center reduction for mouse steering
  • Timer based ignition cut so you don't manually cut the ignition for longer than necessary by holding down the shift up key
  • Throttle blip that can be controlled by how long you hold down the shift down key
  • Independent rate controls for increasing and decreasing throttle, brakes and clutch
  • Addition rate controls for increasing and decreasing throttle and clutch during ignition cut and throttle blip events

if starting:
system.setThreadTiming(TimingTypes.HighresSystemTimer)
system.threadExecutionInterval = 5

def set_button(button, key):
if keyboard.getKeyDown(key):
v.setButton(button, True)
else:
v.setButton(button, False)

def calculate_rate(max, time):
if time > 0:
return max / (time / system.threadExecutionInterval)
else:
return max

int32_max = (2 ** 14) - 1
int32_min = (( 2** 14) * -1) + 1

v = vJoy[0]
v.x, v.y, v.z, v.rx, v.ry, v.rz, v.slider, v.dial = (int32_min,) * 8

# =============================================================================================
# Axis inversion settings (multiplier): normal = 1; inverted = -1
# =============================================================================================
global throttle_inversion, braking_inversion, clutch_inversion
throttle_inversion = 1
braking_inversion = 1
clutch_inversion = 1

# =============================================================================================
# Mouse settings
# =============================================================================================
global mouse_sensitivity, sensitivity_center_reduction
mouse_sensitivity = 25.0
sensitivity_center_reduction = 5.0

# =============================================================================================
# Ignition cut settings
# =============================================================================================
global ignition_cut_time, ignition_cut_elapsed_time
ignition_cut_enabled = True
ignition_cut_time = 100
ignition_cut_elapsed_time = 0

global ignition_cut, ignition_cut_released
# Init values, do not change
ignition_cut = False
ignition_cut_released = True

# =============================================================================================
# Steering settings
# =============================================================================================
global steering, steering_max, steering_min, steering_center_reduction
# Init values, do not change
steering = 0.0
steering_max = float(int32_max)
steering_min = float(int32_min)
steering_center_reduction = 1.0

# =============================================================================================
# Throttle settings
# =============================================================================================
global throttle_blip_enabled
throttle_blip_enabled = True

# In milliseconds
throttle_increase_time = 100
throttle_increase_time_after_ignition_cut = 0
throttle_increase_time_blip = 50
throttle_decrease_time = 100

global throttle, throttle_max, throttle_min
# Init values, do not change
throttle_max = int32_max * throttle_inversion
throttle_min = int32_min * throttle_inversion
throttle = throttle_min

global throttle_increase_rate, throttle_decrease_rate
# Set throttle behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
throttle_increase_rate = calculate_rate(throttle_max, throttle_increase_time)
throttle_increase_rate_after_ignition_cut = calculate_rate(throttle_max, throttle_increase_time_after_ignition_cut)
throttle_increase_rate_blip = calculate_rate(throttle_max, throttle_increase_time_blip)
throttle_decrease_rate = calculate_rate(throttle_max, throttle_decrease_time) * -1

# =============================================================================================
# Braking settings
# =============================================================================================
# In milliseconds
braking_increase_time = 100
braking_decrease_time = 100

global braking, braking_max, braking_min
# Init values, do not change
braking_max = int32_max * braking_inversion
braking_min = int32_min * braking_inversion
braking = braking_min

global braking_increase_rate, braking_decrease_rate
# Set braking behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
braking_increase_rate = calculate_rate(braking_max, braking_increase_time)
braking_decrease_rate = calculate_rate(braking_max, braking_decrease_time) * -1

# =============================================================================================
# Clutch settings
# =============================================================================================
# In milliseconds
clutch_increase_time = 0
clutch_decrease_time = 50

global clutch, clutch_max, clutch_min
# Init values, do not change
clutch_max = int32_max * clutch_inversion
clutch_min = int32_min * clutch_inversion
clutch = clutch_min

global clutch_increase_rate, clutch_decrease_rate
# Set clutch behaviour with the increase and decrease time,
# the actual increase and decrease rates are calculated automatically
clutch_increase_rate = calculate_rate(clutch_max, clutch_increase_time)
clutch_decrease_rate = calculate_rate(clutch_max, clutch_decrease_time) * -1

# =============================================================================================
# Button and key assignments
# =============================================================================================
global clutch_key
clutch_key = Key.C

global shift_up_key, shift_up_button
shift_up_key = Key.W
shift_up_button = 1

global shift_down_key, shift_down_button
shift_down_key = Key.S
shift_down_button = 2

global look_left_key, look_left_button
look_left_key = Key.A
look_left_button = 3

global look_right_key, look_right_button
look_right_key = Key.D
look_right_button = 4

global look_back_key, look_back_button
look_back_key = Key.X
look_back_button = 5

global change_view_key, change_view_button
change_view_key = Key.V
change_view_button = 6

global indicator_left_key, indicator_left_button
indicator_left_key = Key.Q
indicator_left_button = 7

global indicator_right_key, indicator_right_button
indicator_right_key = Key.E
indicator_right_button = 8

# =================================================================================================
# LOOP START
# =================================================================================================

# =================================================================================================
# Steering logic
# =================================================================================================
if steering > 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_max))
elif steering < 0:
steering_center_reduction = sensitivity_center_reduction ** (1 - (steering / steering_min))

steering = steering + ((float(mouse.deltaX) * mouse_sensitivity) / steering_center_reduction)

if steering > steering_max:
steering = steering_max
elif steering < steering_min:
steering = steering_min

v.x = int(round(steering))

# =================================================================================================
# Clutch logic
# =================================================================================================
if (throttle_blip_enabled and keyboard.getKeyDown(shift_down_key)) or (ignition_cut_enabled and ignition_cut_released and keyboard.getKeyDown(shift_up_key)) or keyboard.getKeyDown(clutch_key):
clutch = clutch_max
else:
clutch = clutch + clutch_decrease_rate

if clutch > clutch_max * clutch_inversion:
clutch = clutch_max * clutch_inversion
elif clutch < clutch_min * clutch_inversion:
clutch = clutch_min * clutch_inversion

v.slider = clutch

# =================================================================================================
# Throttle logic
# =================================================================================================
if ignition_cut_enabled and ignition_cut and ignition_cut_elapsed_time < ignition_cut_time:
ignition_cut_elapsed_time = ignition_cut_elapsed_time + system.threadExecutionInterval

if ignition_cut_enabled and not ignition_cut_released and keyboard.getKeyUp(shift_up_key):
ignition_cut_released = True

if throttle_blip_enabled and ((ignition_cut_enabled and not ignition_cut) or (not ignition_cut_enabled)) and keyboard.getKeyDown(shift_down_key):
# Throttle blip
throttle = throttle + throttle_increase_rate_blip
elif ignition_cut_enabled and ignition_cut_released and keyboard.getKeyDown(shift_up_key):
# Ignition cut
throttle = throttle_min
ignition_cut = True
ignition_cut_released = False
ignition_cut_elapsed_time = 0
elif mouse.leftButton:
if ignition_cut_enabled and ignition_cut and ignition_cut_elapsed_time >= ignition_cut_time:
throttle = throttle_max
else:
throttle = throttle + throttle_increase_rate
else:
throttle = throttle + throttle_decrease_rate

if ignition_cut_enabled and ignition_cut and ignition_cut_elapsed_time >= ignition_cut_time:
ignition_cut = False
ignition_cut_elapsed_time = 0

if throttle > throttle_max * throttle_inversion:
throttle = throttle_max * throttle_inversion
elif throttle < throttle_min * throttle_inversion:
throttle = throttle_min * throttle_inversion

v.y = throttle

# =================================================================================================
# Braking logic
# =================================================================================================
if mouse.rightButton:
braking = braking + braking_increase_rate
else:
braking = braking + braking_decrease_rate

if braking > braking_max * braking_inversion:
braking = braking_max * braking_inversion
elif braking < braking_min * braking_inversion:
braking = braking_min * braking_inversion

v.rz = braking

# =================================================================================================
# Buttons post-throttle logic
# =================================================================================================
set_button(look_left_button, look_left_key)
set_button(look_right_button, look_right_key)
set_button(look_back_button, look_back_key)
set_button(change_view_button, change_view_key)
set_button(indicator_left_button, indicator_left_key)
set_button(indicator_right_button, indicator_right_key)

# =================================================================================================
# PIE diagnostics logic
# =================================================================================================
diagnostics.watch(v.x)
diagnostics.watch(v.y)
diagnostics.watch(v.rz)
diagnostics.watch(v.slider)
diagnostics.watch(steering_center_reduction)
diagnostics.watch(throttle_blip_enabled)
diagnostics.watch(ignition_cut_enabled)

Last edited by Skagen, .
Skagen
S3 licensed
Quote from Scawen :Just remember the resolution is still going to be a bit low. This will be a problem in a racing simulator when you are looking far down the road. Maybe the consumer version (developed with facebook money) will have a higher resolution. Just reminding people, with all the hype, it's still just a developer kit and it might be disappointing if you expect too much.

The horizontal resolution in each eye will be 960 pixels, spread over move than 90 degrees, so you can easily see each pixel individually.

But at those resolutions, even older grade hardware should be able to handle supersampling AA to help out the resolution. On my 4 year old laptop, I ran LFS with 4x SSAA, and not only did it help with the annoying flickering from vegetation and fences with alpha channels, but it is also far superior with correcting texture mooshing than anisotropic filtering which is very nice when you're looking really far down the road.

Whatever you plan on doing with the new possibilities with DX9, I hope you will make it possible for people to disable any expensive effects. There is no doubt in my mind that I would take supersampling AA over any eye-candy effects in LFS if I had to make choice between them.
Skagen
S3 licensed
Session: Race
Lap: 21
Timecode: 38:00
Cars: #22 and #42
Description: Car #42 tries to dive to the inside of #22 into turn 7, but end up contacting #22 which is spun off track.
Skagen
S3 licensed
Depends how the limit is set. If it is just an integer threshold value, the amount of layout objects your processor is actually capable of handling makes no difference.
Skagen
S3 licensed
TCP is also slower and can cause big hickups with other cars, since the flow of position data between you and the server can queue up if there is just one tiny bit of information that is taking a very long time to transmit.

With UDP, if one bit of information is lost in transmission, you just get a minor hickup, if not unoticable hickup in many cases.
Skagen
S3 licensed
Quote from DANIEL-CRO :Just because it was always there doesn't mean its not a "bug".
Is it limitation of LFS or graphics limitation...?

Most likekly, Scawen has set a limit in LFS as to how many physic interactions the game will compute for layout objects at any given time. For each layout object that is moving, LFS will have to compute its physics. If there are too many moving layout objects moving around at once, the processor cannot keep up with all the calculations required, and the game will start to lag and skip frames.

To avoid this, the limit is probably set with good margins, and the game will simply not calculate the physics for any additional layout object that is over the set limit. It's just a mechanism for prioritizing more important stuff (like the car physics) before the processor load goes too high. And the message is just verbose.
Last edited by Skagen, .
Skagen
S3 licensed
Drafting was allowed in qualifying?
Skagen
S3 licensed
In my experience with ENB, the result you get with any given setting isn't deterministic. Often I will have a quite different visual result compared to other people who have posted their settings and screenshots. In all these cases, the ENB library has been the same.

I'm no expert, but it could be ENB doing things which isn't supported by the DX API or drivers, which gives different results on different implementations.
Skagen
S3 licensed
You can check out the current world records here: http://www.lfsworld.net/rafa/

I think you can download and watch SPR (replays) of hotlaps for valid demo combos, i.e XFG@BL1.
Skagen
S3 licensed
Quote from Kyotee :I know, but as you said, if you can't automatically supersample with ENB enabled, why not force it manually?

Quote from Skagen :(...) for textures at the angles you often see the road ahead of you while driving. It just gives a much better degree of fine detail in the image, and the image is generally calmer since there is no pixelation from transparent textures, etc.

Skagen
S3 licensed
Quote from Kyotee :I know how it works, silly. In that case, why not just render at a higher resolution, providing your PC can handle it? If not, then, oh well.

That is what supersampling is; rendering the frame at very high resolutions. With supersampling, my GPU is rendering LFS at 7680 x 4320, and averaging every 4 x 4 block down to 1920 x 1080 which is my laptops screen resolution.
Skagen
S3 licensed
Quote from boothy :It's what happens when your tracker name doesn't match your in-game name, the tracker doesn't know you've finished. (S. A. Skagen vs S.Skagen)

How does it recognize my laps if it doesn't recognize me finishing the race? Wouldn't it be safer to use usernames instead?
Last edited by Skagen, .
Skagen
S3 licensed
Ah ok
Skagen
S3 licensed
According to the tracker, #22 KnS got 1 lap penalty. I don't remember seeing any text from admin about us getting a penalty. What was it for?
Skagen
S3 licensed
#22 KnS
Skagen
S3 licensed
Dave (cargame.nl) hosted the 24h of MoE if I don't remember wrong. Maybe he can help out if all else fails?
Skagen
S3 licensed
Are you sure there is no one else connected to your wireless point using bandwidth? You can log in and check the DHCP client list to see what units have been assigned an adresse on your network.

You can also use tools like insSIDer to check if there is any signal interference with other wireless networks and units in your area.
Skagen
S3 licensed
Team name: KnS
Number: 22
Car: FZR
Drivers:
skagen, Skjalg Axelsen Skagen, Norway
ghostfight3r, Daniel Kirsten, Germany
Skagen
S3 licensed
Sorry, I haven't tested the skins myself. But I'm guessing it's the sort when you have two overlapping surfaces? I don't see any reason for it to happen unless the geometry of the race track was changed.
FGED GREDG RDFGDR GSFDG