Community Forum

.lua command for activating in game beacons

Forum Overview >> Farming Simulator 2011

CategoryFarming Simulator 2011
Created13.08.2011 01:40


Jim Nonya (Clampit) 13.08.2011 01:48
I am working with a .lua for Interactive Controls. I am wanting to place a button for activating the beacons that are operated by the game. Here is an example of the command I am working with pertaining to a button function.

if self.event == "togglefrontwork" then
if self.vehicle ~= nil then
self.vehicle:setState("work:1",not self.vehicle.B3.work[1].a);
end;
end;

What does this line "self.vehicle:setState("work:1",not self.vehicle.B3.work[1].a);" need to say to activate all the beacons that are operated by the game?
Thank you for your help.

Harry Paul Jones (Unknown) 28.08.2011 00:22
I think the easiest option is to make a script for the beacon on the tractor yourself , that way you can call it form the same script , im still learning lua and like to know how to call function from other lua files , would be interesting to find out.

Knut Are Nybo (knybo) 09.09.2011 07:00
maybe this:
self:setBeaconLightsVisibility(not self.beaconLightsActive);

I haven't tested but I'm doing the same myself so I will test it soon.

Jim Nonya (Clampit) 10.09.2011 01:27
Thank you so much, this worked

self.vehicle:setBeaconLightsVisibility(not self.vehicle.beaconLightsActive);

I don't know enough about .lua to write a script for beacons and the ones that you can find are not MP (they are for LS09). I only play MP so it was best just to use what came with the game.
What I have found though is to call functions from other .lua scripts in the mod just start the command with "self.vehicle". This entry was done on InteractiveButtons.lua in the Interactive Control mod to call function from worklights (thanks to simon11b for the command line information) using beleuchtungV3.lua, manual ignition using manualIgnition.lua, and the in game beacon using the vehicle.lua that Giants wrote.

function Button:doAction(dt)
if self.event == "togglefrontwork" then
if self.vehicle ~= nil then
self.vehicle:setState("work:1",not self.vehicle.B3.work[1].a);
end;
end;
if self.event == "togglerearwork" then
if self.vehicle ~= nil then
self.vehicle:setState("work:2",not self.vehicle.B3.work[2].a);
end;
end;
if self.event == "toggleIGNITION" then
if self.vehicle ~= nil then
self.vehicle.ignitionKey = not self.vehicle.ignitionKey;
self.vehicle.allowedIgnition = true;
end;
end
if self.event == "toggleBeacon" then
if self.vehicle ~= nil then
self.vehicle:setBeaconLightsVisibility(not self.vehicle.beaconLightsActive);
end;
end
end;


Note: Log in to post. Create a new account here.