Smallg a long time a go you corrected a carry_object script of wermer .
https://forum.game-guru.com/thread/214085#msg2536346
here is his script.
unction carry_object_init(e)
cmode = 0
end
function carry_object_main(e)
if (GetPlayerDistance(e) < 80) and (cmode == 0) then
Prompt("Press E to carry")
if g_KeyPressE == 1 then
cmode = 1
end
end
if (cmode == 1) then
new_y = math.rad(g_PlayerAngY)
prop_x = g_PlayerPosX + (math.sin(new_y) * 70)
prop_z = g_PlayerPosZ + (math.cos(new_y) * 70)
CollisionOff(e)
SetPosition(e , prop_x, g_PlayerPosY , prop_z)
RotateToCamera(e)
CollisionOn(e)
Prompt("Release E to drop")
if g_KeyPressE == 1 then
cmode = 0
CollisionOff(e)
SetPosition(e , prop_x , g_PlayerPosY , prop_z)
CollisionOn(e)
end
end
end
Here is the script you corrected.
local nearest = nil
local nearest_dist = 80
local int_nearest_dist = nearest_dist
local cmode = 0
local new_y = 0
local prop_x = 0
local prop_z = 0
function carry_object_init(e)
cmode = 0
end
function carry_object_main(e)
if cmode == 0 then
if nearest == nil then
nearest_dist = int_nearest_dist
elseif GetPlayerDistance(nearest) > nearest_dist then
nearest_dist = int_nearest_dist
end
if GetPlayerDistance(e) < nearest_dist then
nearest_dist = GetPlayerDistance(e)
nearest = e
end
if (GetPlayerDistance(e) <= nearest_dist) then
Prompt("Press E to carry")
if g_KeyPressE == 1 then
cmode = 1
nearest = e
return
end
end
elseif (cmode == 1) then
new_y = math.rad(g_PlayerAngY)
prop_x = g_PlayerPosX + (math.sin(new_y) * 70)
prop_z = g_PlayerPosZ + (math.cos(new_y) * 70)
CollisionOff(nearest)
SetPosition(nearest , prop_x, g_PlayerPosY , prop_z)
RotateToCamera(nearest)
CollisionOn(nearest)
Prompt("Release E to drop")
if g_KeyPressE == 0 or GetPlayerDistance(nearest) > init_nearest_dist then
cmode = 0
CollisionOff(nearest)
SetPosition(nearest , prop_x , g_PlayerPosY , prop_z)
CollisionOn(nearest)
nearest = int_nearest_dist
nearest = nil
end
end
end
Here is my Question. you said you have corrected his script .
Quote: "
it's just because of the way you are using it there, what's actually happening is while you are holding 'e' to carry the object the object is in actual fact getting dropped and picked up in a very quick time and thus you don't notice... it does work but obviously not quite what you intended
i did notice that my script wouldn't work for hitting the carried object on obstacles though and thus not dropping it if it became out of range (while your version would inadvertently do so) so i have added an extra distance check.
"
I wanted to use your script, because it sounded if its going to work better.
but when i run your script i get an error message , see picture attach.
When i use wermer's script its working with out an error.
but i can see what you mean by the object is being dropped all the time.
So i was wandering if you can have a look at the script again that you made and see why its giving me this error
Ps ... apologies for spelling Smallg wrong in the title
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 4GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11