Postby Mercury002 » Sat Feb 14, 2015 3:05 pm
Ok the code you will use is generic, however some of the code is unnecessary for example this code will work just as well;
function Create()
local x = Object.GetProperty("Pos.x")
local y = Object.GetProperty("Pos.y")
local NAME_OF_YOUR_SCRIPT = Object.GetNearbyObjects ("Fire", 3) -- detects fire in 3 squares
for name,distance in pairs(NAME_OF_YOUR_SCRIPT) do
INSERT YOU CODE
Object.Spawn("Water", x, y) -- spawns water on top of object
end
else
INSERT YOU CODE
end
end
This is not the main problem of the code however, I've tried something similar in order to add water around watery objects like the sink, shower ect, if there is a fire nearby.
The problems are that while Object.Spawn works and can spawn anything (even supply trucks or more prisoners). If water is spawned, the code doesn't throw back any errors, however the water does not appear, perhaps it evaporates automatically really quickly like the fire hose and much more quantity needed?.
The main problem however is that while the Object.GetNearbyObjects works on all objects just as above, detecting fire is a different issue, It will activate code upon detecting the fire and throw back errors, this could be due to the nature of the fire. Fire grows and shrinks and spreads to other squares, so it is possible that the object "Fire" is only relevant at the very moment a fire spawns and then other objects/scripts are used to spread fire.
I tired to make ... flammable/explosive objects by using the code above to detect fire on top of the object Object.GetNearbyObjects ("Fire", 0) and then spawn fire all around the object and then delete the object (MUST DELETE THE OBJECT, otherwise it may create a loop of detecting fire and spawning fire infinity),. However this worked if the code was changed to discover anything else other than fire (haven't tried water but it might be the same), ie supply truck is nearby and boom the explosive goes off burning the driver