So I've been working on another game for my wife this year and I have two free scripts to give back to you guys.
The first is a modified sound zone that allows you to setup multiple sound zones throughout a level and will freeze the player when they are in it for 4500 ms and then unfreeze them afterwards.
It's very easy to use, simply set a trigger zone, assign the script, and assign the sound file you want to use.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Sound Zone
sound_fOnce = {}
function sh_soundinzone1_init(e)
sound_fOnce[e] = 0
end
function sh_soundinzone1_main(e)
if g_Entity[e]['plrinzone']==1 then
if sound_fOnce[e]==0 then
FreezePlayer()
PlaySound(e,0)
--Destroy(e)
ActivateIfUsed(e)
StartTimer(e)
local timerval=GetTimer(e)
sound_fOnce[e]=1
end
timerval = GetTimer(e)
remtime = (4500 - timerval) / 1000
Prompt("Player movement paused. Movement Resumed in: " .. remtime .. "Seconds")
if timerval >= 4500 and sound_fOnce[e]==1 then
UnFreezePlayer()
sound_fOnce[e] = 2
elseif sound_fOnce[e] == 2 then
-- do nothing
end
end
The second script is a simplified, modified teleport script based on one I found on the forums years ago. You assign it to a static object (in this case, a wooden palette) and then point it to an object on the 'ifused' property field of the script. It can point to nearly anything in the game though I just end up using more palettes because I'm lazy.
Anyways here's the script.
-- LUA Script - precede every function and global member with lowercase name of script
objname = {}
function sh_tele_init(e)
end
function sh_tele_init_name(e, name)
objname[e] = name
end
function sh_tele_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist <= 150 then
if objname[e] == "Wooden Pallet (Single)" then
PromptLocal(e, "Press H/h to open the door.")
end
if g_InKey == "h" then
-- Prompt("Debug: key pressed")
TransportToIfUsed(e)
end
end
end
Merry christmas
I will probably include these two as part of my upcoming library of utility scripts.