Author Message

RedCarDriver

us
Posts: 1211

Location: United States Arizona
Occupation: it's complicated... more complicated than my relationships
Age: 30
V$: 86310
#151368   2018-11-15 23:01          
# amilmand : Almost there but as you found out (judging by the static cast to int) this function returns a float soo its no good for you the full call would be to get the address of the value and decode it as an int:
RawEdit.getI(the_car.getIndexedAddr(Chassis.IndexedData_Flags));
The clues would have been: LINK
And the comments in the chassis.java:
public static final int IndexedData_GearNumber = 0x20FC-0x304;
   //this is an int getIndexedData will return
     strange but the RawEdit.getI with getIndexedAddr will suffice
public static final int IndexedData_Flags = 0x70;//int
Thanks, I think that was what I needed. It's returning really weird values, though. It doesn't seem to be correctly changing when the turn signals turn on.

I dont know what your goal is with the flags but I found that access to this value is of a readonly manner as most of the flags the game updates each frame and invalidates any changes you try to force (though you can get interesting state indicators so to say, (whether the blinker is on, is the car running and some others)
The idea here is to program something like American turn signals, where a single red light is shared for the city, brake, and turn signal functions, and the light turns off entirely when the turn signals are on at the same time as the brake or city lights. (Reference if you have no idea what I'm talking about.)

So basically, the pseudocode should go like this:
if flags & 1
 > if flags & 16
 > > turn off brake light
 > otherwise
 > > turn on brake light
if flags & 1
 > if flags & 16
 > > turn off city light
 > otherwise
 > turn on city light
if !(flags & 1) && !(flags & 4)
 > if flags & 16
 > > turn on brake light
But I can't quite get the flags to work.

By the way, is there a convenient way to display a glow object (or other render) aligned to a part, through Java, besides making it a whole separate part that can then be manipulated? I haven't figured this out yet. I have figured out how to display a render as a child of the part, but it always shows up at the center of the map. I can in fact make attachment parts for all of the glow objects, and then make them disappear under the map by moving their slot position, but I'd prefer not to do this if there is a more light-weight alternative (in terms of part count as well as not slowing down the game).

This post was edited by RedCarDriver (2018-11-15 23:21, ago)