The online racing simulator
Searching in All forums
(921 results)
DarkTimes
S2 licensed
I think most Britons are upset about the popes visit as there is growing evidence that he has been part of an international criminal conspiracy to cover-up child rape. The amount of money is not relevant, why should we pay a single penny to allow this man to come here? I have signed the petition to have the pope arrested at Heathrow airport. Sadly as he is a religious leader he is exempted from the law.
DarkTimes
S2 licensed
Heh, I can see this being a nice and relaxed thread.

I'm an atheist. I toyed with antitheism for a bit, mainly after reading Dawkins, but I'm not really against religion. So long as the government is secular and schools teach (actual) science, people can believe what they want so long as they don't hurt other people.
DarkTimes
S2 licensed
Ah right, I think I get you. Yeah, you could use it to send commands from the console to LFS.

import pyinsim

print 'Enter command and press return to send, or press CTRL+Z to exit'

insim = pyinsim.InSim()

try:
insim.init('localhost', 29999)

while True:
cmd = raw_input('Enter Command: ')
insim.sendm(cmd) # Send command!

except EOFError:
insim.close()
except pyinsim.Error as err:
print 'InSim Error: %s' % err

DarkTimes
S2 licensed
I don't know the solution to that problem, you might need to ask in the hosts forum.
DarkTimes
S2 licensed
Quote from mstram :Hi D.t.,

Ok, I'll give that a try.

I had tried running that server before, the instructions are not very clear about where to setup the config info. I tried editing the setup.cfg file, but when I start the server it's ignoring / over writing the settings.

It sure doesn't have as nice an interface for settings as the multiplayer screen in the LFS client.

I'll revisit it , and I saw there was a network "sticky", I'll re-read it, and see what the issue is with it

Yeah it can be a bit tricky the first time, after that it's easy though. Here is a quick guide
  • Download the dedi-server
  • Open the file setup.cfg with your favourite code editor
  • Locate the line that says '//insim=29999' and change it to say '/insim=29999'
  • Find the line '/usemaster=yes' and change it to '/usemaster=no' (optional but good for devlopment)
  • Start the dedi-server by double-clicking the exe
  • Run the cruise.py script from either the command line or from your Python IDE
  • Confirm in the dedi-server window that 'pyCruise' has connected
  • Start LFS, go to Multiplayer, select Join Specific Host, then choose the Local Network tab
  • Set the Host IP address to '127.0.0.1' and the Host port to 63392
  • Click Go in LFS and confirm you have connected to the host
That should work for you, if it does not then I will need more information.

Edit: LFS will overwrite your config if you edit it while the program is running. You need to stop LFS, edit the config, then restart it.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
I'm not sure what you mean, Dygear.
DarkTimes
S2 licensed
The cruise.py script needs to be connected to a dedi-server in order to work. It won't work if you just connect it to a local LFS client. You can download the dedi and run it on your local computer, connect cruise.py to it, then start LFS and connect to the dedi using the Local Network option in Join Specific Host.

It may be possible to run the cruise script on a local copy of LFS, if you open it up and change the constant

HOST_ID = 0

to some other value (not between 0 and 255), such as

HOST_ID = -1

#or

HOST_ID = 256

But I've not tested this and most likely some things will break horribly.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
If you want to use a key to exit the program you can simply do this.

import pyinsim

insim = pyinsim.InSim()
insim.init()

raw_input('Press <ENTER> to exit')

insim.close()

In the current beta this actually causes an exception to be thrown on closing (still closes though ), but I have fixed that in my development version.
DarkTimes
S2 licensed
The cruise.py example only works if you're connected to a dedi-server, I think that might be the problem. I guess I should write that somewhere in it.
DarkTimes
S2 licensed
No, it shouldn't be indented. It's not in my version. Not sure why that is, maybe your IDE interpreting the spaces wrongly.

I was just thinking of that keypress issue today while I was checking the examples. I might need to think about that. I'm not 100% sure that should be a part of pyinsim itself though, as it's kinda of outside its realm. It's not difficult to add it yourself, but it's a bit too late on a Saturday night for me to code up an example now, but I'll think about it more when I'm sober tomorrow.
DarkTimes
S2 licensed
You can delete the try/except block in an example, which should give you a stacktrace, but I don't think you will get much more info if it's just a InSim Init message (this is the error that's thrown when no other message is applicable).

You could try this, the simplest pyinsim program:

import pyinsim

insim = pyinsim.InSim()
insim.init('localhost', 29999)

I'm running the examples now and they work fine for me.

Edit: I just installed Python 2.6 to make sure and it's still working fine.

EditEdit: Some Python IDEs do allow debugging, but it depends on which one you are using.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
@mstram

Heya, I'm not sure what the problem is. Are you using the examples from the old version with the beta? If so they won't work as the API was changed. There are new examples included with the beta that should be OK. If you're not then I would need to see the code you're trying to run to figure out what the problem is.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
Coulthard may not be the best driver ever, but he's still an order of magnitude better than any of us could ever be, and I think his opinion deserves to be respected.
DarkTimes
S2 licensed
Yeah damn these idiots who actually drove in Formula 1. It's obvious they know nothing about the sport! I mean, Coulthard only won 13 grand prix. I just sit about watching races in my underwear. How dare he have an informed opinion.

Edit: 13
Last edited by DarkTimes, .
DarkTimes
S2 licensed
When you see it from this angle it does look very close.

http://twitpic.com/2aq2l4
DarkTimes
S2 licensed
struct IS_MSO // MSg Out - system messages and user messages
{
byte Size; // 136
byte Type; // ISP_MSO
byte ReqI; // 0
byte Zero;

byte UCID; // connection's unique id (0 = host)
byte PLID; // player's unique id (if zero, use UCID)
byte UserType; // set if typed by a user (see User Values below)
byte TextStart; // first character of the actual text (after player name)

char Msg[128];
};

// User Values (for UserType byte)

enum
{
MSO_SYSTEM, // 0 - system message
MSO_USER, // 1 - normal visible user message
MSO_PREFIX, // 2 - hidden message starting with special prefix (see ISI)
MSO_O, // 3 - hidden message typed on local pc with /o command
MSO_NUM
};

System messages are sent as an MSO packet with the UserType field set to MSO_SYSTEM.
DarkTimes
S2 licensed
Yeah, I would use LINQ too, I just didn't in my example because I didn't know if skywatcher understood it and I didn't want to complicate the code unnecessarily.

I guess it's down to personal preference, but I would still use the regex to split the words, as otherwise you run into what I call the S****horpe problem. Edit: the LFS forum has this issue too it seems.

bool MessageContainsSwearWord(string message)
{
return Regex.Split(message, @"\W+").Any(w => swearwords.Contains(w.ToLower()));
}

As I say though it's down to personal preference whether you want to check only whole words or not. Of course it's not the most complete swear-filter ever, but it should work for most simple purposes.
DarkTimes
S2 licensed
Last edited by DarkTimes, .
DarkTimes
S2 licensed
I think Webber has been hugely impressive this year, really driving brilliantly. I was never his biggest fan, but to be honest I'm thinking of getting behind him for the championship. He has exceeded my expectations and then some.
DarkTimes
S2 licensed
"That car is completely unique, except for the one behind it which is identical" - Murray 'Legend' Walker
Last edited by DarkTimes, .
DarkTimes
S2 licensed
In other news, both Mercedes and Renault fined $50,000 each for being unsafe in the pitlane.
DarkTimes
S2 licensed
Quote from spookthehamster :http://www.youtube.com/watch?v=elyxIhMW_No

A video of what you're showing us out of context. Webber is at the right of the track long before Massa comes along. Schuey waited for Barichello to get close then pushed him over.

Yes, from that video it's clear that it's a totally different situation. Webber had successfully blocked Massa way earlier, it was Massa's choice to go so close to the barriers to try and squeeze past. Conversely Schumi waited for Rubens to get alongside and then tried to make him get out of it by pushing him into the wall. Two very different situations.
DarkTimes
S2 licensed
I know other drivers do squeeze occasionally, but Schumacher does it every time another car is alongside. Back in Canada he even took Massas wing off. Frankly the stewards need to send him a message that his driving is too aggressive.

I've said this before I know, but back when he was challenging for championships his aggression was understandable. But honestly now while he's pottering around several seconds off the pace it's just pointless and dangerous.

Rubens was having a better race in a better car, he was going to pass eventually, Schumi's move was totally unnecessary and utterly dangerous.
Last edited by DarkTimes, .
DarkTimes
S2 licensed
The JSON deserializer works really well actually. I've written a little LFSWorld object that can handle doing the queries for you and returns a decoded JSON object.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;

namespace LfsWorldExample
{
public class LfsWorld
{
private string _identKey;

public LfsWorld(string identKey)
{
_identKey = identKey;
}

public Uri CreatePubStatUrl(object args)
{
var url = new StringBuilder();
url.AppendFormat(
"http://www.lfsworld.net/pubstat/get_stat2.php?version=1.4&idk={0}&s=1",
_identKey);

foreach (var property in args.GetType().GetProperties())
{
url.AppendFormat(
"&{0}={1}",
property.Name,
property.GetValue(args, null));
}

return new Uri(url.ToString());
}

public Stream GetResponse(Uri url)
{
var request = WebRequest.Create(url);
var response = request.GetResponse();
return response.GetResponseStream();
}

public T GetJsonResponse<T>(Uri url)
{
using (var stream = GetResponse(url))
{
var json = new DataContractJsonSerializer(typeof(T));
return (T)json.ReadObject(stream);
}
}

public IQueryable<T> Query<T>(object args)
{
var url = CreatePubStatUrl(args);

return GetJsonResponse<List<T>>(url).AsQueryable();
}
}
}

To use it you first of all need to create a data-contract for the JSON results you want to deserialize, which at its simplest is basically just an object with each property named after the corresponding JSON field in the pubstat response.

Here is a very simple data-contract for the host list.

[DataContract]
public class Host
{
[DataMember]
public string hostname;
[DataMember]
public string tmlt;
[DataMember]
public string tcrm;
[DataMember]
public int cars;
[DataMember]
public int rules;
[DataMember]
public int laps;
[DataMember]
public int qualmins;
[DataMember]
public string country;
[DataMember]
public int nrracers;
[DataMember]
public List<string> racers; // It supports lists
}

Then you can create simple queries to request the list of hosts like this.

var lfs = new LfsWorld("<your ident key>");

var hosts = lfs.Query<Host>(new
{
action = "hosts",
});

The query is returned as a type of IQueryable, so you can perform LINQ operations on it. For instance if you wanted to get a list of only the populated hosts (hosts with one or more drivers) you could do a simple query like this.

var lfs = new LfsWorld("<your ident key>");

var hosts = lfs.Query<Host>(new
{
action = "hosts",
});

var populatedHosts = from h in hosts
where h.nrracers > 0
orderby h.nrracers descending
select h;

foreach (var host in populatedHosts)
{
Console.WriteLine(host.hostname);
}

You can pass multiple arguments into the query method, so to request a list of a players personal bests you could do this:

var lfs = new LfsWorld("<your ident key">);

var pbs = lfs.Query<PersonalBest>(new
{
action = "pb",
racer = "DarkTimes",
});

foreach (var pb in pbs)
{
// etc..
}

Or to request the hotlaps for a specific car and track.

var lfs = new LfsWorld("<your ident key>");

var hotlaps = lfs.Query<HotLap>(new
{
action = "ch",
track = "BL1",
car = "FBM",
});

Last edited by DarkTimes, .
DarkTimes
S2 licensed
Quote from CrAZySkyPimp :Damn I missed the finish, what did Vettel say on the radio after the race?

Wasn't on the radio, he was arguing with the steward in the podium room after the race.
FGED GREDG RDFGDR GSFDG