Hello!
i am in need of assistance, as i am trying to put images in my "key" scripts, but the problem is that only one
of them works at a time, i don't know what im doing wrong!
Here are my scripts:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Key
function keyaxe_init(e)
LoadImages("pic1",0)
SetImagePosition(80,50)
SetImageAlignment(1)
end
function keyaxe_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 20.0 then
--[[
SourceAngle = g_PlayerAngX
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 335.0 do
SourceAngle = SourceAngle - 360.0
end
DestAngle = math.atan2( PlayerDZ , PlayerDY )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 25.0 then
--]]
Prompt ("Press E To pick up hammer")
if g_KeyPressE == 1 then
PromptDuration("Collected hammer",3000)
PlaySound(e,0)
Collected(e)
ShowImage(0)
Destroy(e)
ActivateIfUsed(e)
end
--end
end
end
end
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Key
function levelonekeycard_init(e)
LoadImages("pic1",1)
SetImagePosition(75,40)
SetImageAlignment(1)
end
function levelonekeycard_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 150 and g_PlayerHealth > 0 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
PlayerDX = (g_Entity[e]['x'] - g_PlayerPosX)
PlayerDZ = (g_Entity[e]['z'] - g_PlayerPosZ)
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 20.0 then
--[[
SourceAngle = g_PlayerAngX
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 335.0 do
SourceAngle = SourceAngle - 360.0
end
DestAngle = math.atan2( PlayerDZ , PlayerDY )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if Result < 25.0 then
--]]
Prompt ("Press E To pick up level 1 keycard")
if g_KeyPressE == 1 then
PromptDuration("Collected keycard",3000)
PlaySound(e,0)
Collected(e)
ShowImage(1)
Destroy(e)
ActivateIfUsed(e)
end
--end
end
end
end
My images are located in scriptbank/images/pic1
The thing what im trying to make is to create icons in screen for "key" items, kinda like a light inventory system.
thank you in advance if you can help me!
Intel Core i5 6600K @ 3.50GHz ¨ 16,0Gt dual channel RAM @ 1334MHz ¨¨ 2048MtNVIDIA GeForce GTX 1060 6GB ¨¨ 465GB Samsung SSD 750 EVO 500GB (SSD) ¨¨ Windows 10 Home 64-bit