-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- quest1 function quest1_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if timerstarted == 1 then time = time - 1 end if time < 1 then Prompt("Quest Failed") quest1started = 0 stolensupplies = 0 end if PlayerDist < 80 then if quest1started == 0 then questreward = 5000 Prompt("Help me get back some stolen supplies from the nearby bandits, press E to accept"); if g_KeyPressE == 1 then quest1started = 1 timerstarted = 1 time = 500 end else if stolensupplies == 1 then Prompt("Thank you! *press E to complete quest*") if g_KeyPressE == 1 then Prompt("£" .. questreward .. " given") money = money + questreward stolensupplies = 0 timerstarted = 0 time = 500 end end end end end
time = 500
-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY' -- state to ensure user must release E key before can open/close again door_pressed = 0 function door_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 100 then if g_Entity[e]['activated'] == 0 then if doorkey == 3 then Prompt("The door is locked. insert the keys? *'E' to unlock*"); if g_KeyPressE == 1 then g_Entity[e]['activated'] = 1; end else doorkeysremaining = 3 - doorkey Prompt("The door is locked. Find the " .. doorkeysremaining .. " keys to unlock door"); end else if g_Entity[e]['activated'] == 1 then -- door is unlocked and closed Prompt("Press E to open door"); if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then SetAnimation(0); PlayAnimation(e); g_Entity[e]['animating'] = 1; g_Entity[e]['activated'] = 2; PlaySound0(e); CollisionOff(e); door_pressed = 1; end else if g_Entity[e]['activated'] == 2 then -- door is open if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then SetAnimation(1); PlayAnimation(e); g_Entity[e]['animating'] = 1; g_Entity[e]['activated'] = 1; PlaySound1(e); CollisionOn(e); door_pressed = 1; end end end end end if g_KeyPressE == 0 then door_pressed = 0; end end
function multikey_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 80 then PlaySound0(e); Collected(e) Destroy(e); doorkey = doorkey + 1 end end
doorkey = 0
-- Globals (built-in) L = {} -- Globals (passed-in) codegiven = 0 code1 = 0 code2 = 0 code3 = 0 code4 = 0 code5 = 0 keycode = 1
function randomnumber_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); Le = 1 for i = 1, 5 do --generates a variable with 5 different values L[i] = Le Le = Le + 1 --not technically needed i think but it makes it easier to see which L[i] is which if needed end if PlayerDist < 80 and Pressed == 0 and codegiven == 0 then Prompt("*Press 'E' to generate code*") if g_KeyPressE == 1 then math.randomseed(100) a = math.random(1,5) --generates a random number between 1 and 5 (inclusive) b = math.random(1,5) c = math.random(1,5) d = math.random(1,5) f = math.random(1,5) Prompt(L[a] .. " - " .. L[b] .. " - " .. L[c] .. " - " .. L[d] .. " - " .. L[f]) Pressed = 1 codegiven = 1 end else if g_KeyPressE == 0 then Pressed = 0 end if codegiven == 1 then Prompt("CODE REQUIRED = " .. L[a] .. " - " .. L[b] .. " - " .. L[c] .. " - " .. L[d] .. " - " .. L[f] .. " CODE SO FAR = " .. code1 .. " - " .. code2 .. " - " .. code3 .. " - " .. code4 .. " - " .. code5) end end end
function code_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 90 and pressed == 0 then showing = 1 if keycodeset == 0 then code = math.random(1,5) keycodeset = 1 end Prompt("KEYCODE = " .. code) if g_KeyPressE == 1 and pressed == 0 then --if code1 < 1 then --add this check and remove the "if keycode == 2 then" below if u want the code to be added in any order so long as number is correct i.e. 0 - 0 - 2 - 0 - 0 if keycode == 1 then --remove this for any order input if code == L[a] then --checks value picked up is correct otherwise goes to else command PlaySound0(e); code1 = code --used later to compare picked up values to final code at door pressed = 1 --good way to delay the 'E' key keycode = keycode + 1 --tells the if statements that number 1 has been picked up and so now needs to look at the next number return --stops multiple number pickups from being input at once if code is for eg 1 - 1 - 1 - 3 - 4 then without the return a single pickup of 1 would insert 1 - 1 - 1 - 0 - 0 instead of the 1 - 0 - 0 - 0 - 0 as expected else Prompt("WRONG CODE") --simple code here just to inform wrong number attempted to pickup but you can easily force a reset of numbers or some such here end end --end --if code2 < 1 then if keycode == 2 then if code == L[b] then PlaySound0(e); code2 = code pressed = 1 keycode = keycode + 1 return else Prompt("WRONG CODE") end end --end --if code3 < 1 then if keycode == 3 then if code == L[c] then PlaySound0(e); code3 = code pressed = 1 keycode = keycode + 1 return else Prompt("WRONG CODE") end end --end --if code4 < 1 then if keycode == 4 then if code == L[d] then PlaySound0(e); code4 = code pressed = 1 keycode = keycode + 1 return else Prompt("WRONG CODE") end end --end --if code5 < 1 then if keycode == 5 then if code == L[f] then PlaySound0(e); code5 = code pressed = 1 keycode = keycode + 1 Destroy(e); --to remove the random number generator pickup when all codes are correctly pickedup (could technically set a single variable here to true and unlock the door that way instead of doing a full code check again but either way works fine and this allows for better function with the alternative random pickup sequence) else Prompt("WRONG CODE") end end --end end else --showing = 0 keycodeset = 0 end --end if g_KeyPressE == 0 then pressed = 0 end end
-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Door Prompts 'Closed' can be opened with entity collected specified by 'USE KEY' -- state to ensure user must release E key before can open/close again door_pressed = 0 function keycodedoor_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 100 then if g_Entity[e]['activated'] == 0 then if code1 == L[a] and code2 == L[b] and code3 == L[c] and code4 == L[d] and code5 == L[f] then --final check that all numbers picked up match the initial code generated Prompt("Insert the keycode? *'E' to unlock*"); if g_KeyPressE == 1 then g_Entity[e]['activated'] = 1; PlaySound1(e); door_pressed = 1 end else Prompt("The door is locked. Insert the correct code to unlock it"); end else if g_Entity[e]['activated'] == 1 then -- door is unlocked and closed Prompt("Door Unlocked! *Press 'E' to open*"); if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then SetAnimation(0); PlayAnimation(e); g_Entity[e]['animating'] = 1; g_Entity[e]['activated'] = 2; PlaySound0(e); CollisionOff(e); door_pressed = 1; end else if g_Entity[e]['activated'] == 2 then -- door is open if g_KeyPressE == 1 and g_Entity[e]['animating'] == 0 and door_pressed == 0 then SetAnimation(1); PlayAnimation(e); g_Entity[e]['animating'] = 1; g_Entity[e]['activated'] = 1; PlaySound1(e); CollisionOn(e); door_pressed = 1; end end end end end if g_KeyPressE == 0 then door_pressed = 0; end end
-- LUA Script - precede every function and global member with lowercase name of script + '_main' timeset = 0 darkness = 90 --changes the lighting quicker at first (to allow quicker transition between light and dark places) 1 is on / 0 is off fasterinitchange = 1 --how quickly the lighting changes (1 is slow, 20 is quick) changeamount = 15 function darkzone_main(e) if timeset == 0 then time1 = GetTimer(e) timeset = 1 end --Prompt(darkness) --optional prompt to show how quickly darkness is changing time2 = GetTimer(e) if time1 + 100 < time2 then time1 = GetTimer(e) if g_Entity[e]['plrinzone']==1 then if darkness > 0 then SetFogNearest(darkness * 5) SetFogDistance(darkness * 100) SetFogRed(darkness) SetFogGreen(darkness) SetFogBlue(darkness) SetAmbienceIntensity(darkness) SetAmbienceRed(darkness) SetAmbienceGreen(darkness) SetAmbienceBlue(darkness) SetSurfaceRed(darkness) SetSurfaceGreen(darkness) SetSurfaceBlue(darkness) darkness = darkness - changeamount if darkness > 60 and fasterinitchange == 1 then darkness = darkness - (changeamount * 4) end end else SetFogNearest(99999) SetFogDistance(100000) if darkness < 100 then darkness = darkness + changeamount if darkness < 40 and fasterinitchange == 1 then darkness = darkness + (changeamount * 4) end SetFogRed(darkness) SetFogGreen(darkness) SetFogBlue(darkness) SetAmbienceIntensity(darkness) SetAmbienceRed(darkness) SetAmbienceGreen(darkness) SetAmbienceBlue(darkness) SetSurfaceRed(darkness) SetSurfaceGreen(darkness) SetSurfaceBlue(darkness) end end end end
local checked = {} local promptd2 = 0 --set to amount of damage you want applied each time an ally is killed local damage = 50 --change value here to adjust amount of time prompt will appear on screen local promptdelay = 100 --this is the start and end (e) numbers of your entities (first and last placed - place them in sequence) local enemyEN = 2 local enemyendEN = 9 --store init prompt time promptd2 = promptdelay for a = enemyEN, enemyendEN do checked[a] = 0 end function friendlyfire_main(e) for a = enemyEN , enemyendEN do if checked[a] == 0 then if g_Entity[a] ~= nil then if g_Entity[a]['health'] < 1 then checked[a] = 1 end --end HP below 1 check end --end (e) exists check end --end of check if checked[a] == 1 then if promptdelay > 0 then Prompt("Friendly Fire!") promptdelay = promptdelay - 1 else promptdelay = promptd2 checked[a] = 2 HurtPlayer(e,damage) end --end show prompt end --end checked = 1 end --end for loop end --end of function
function prompte_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); if PlayerDist < 100 then Prompt(e) end end
-- LUA Script - precede every function and global member with lowercase name of script + '_main' local timeset = 0; local time1 = 0; local time2 = 0 --set value here to delay desired between each cycle (in seconds) --60 = 1 min ... / ... 120 = 2mins ... etc local cycle_time = 10 --turn fog on/pff (1/0) local fogon = 1 --set to 0 if you want to use a custom fog colour) local fogcolouron = 1 --set to 0 if you want to use the ambiance slider (set to 1 for quicker darkness at night) local ambi = 0 --set to 1 to start during the day, 0 to start at night local daytime = 1 --time of day/night (0 = midday/midnight) local change = 50 --set to 1 to display the prompt on screen local optional_prompt = 1 ---------do not change below unless you understand :) cycle_time = (cycle_time / 60) * 1000 function day_night_init(e) end function day_night_main(e) if timeset == 0 then time1 = GetTimer(e) timeset = 1 end --optional prompt to show speed of change in numbers if optional_prompt == 1 then Prompt(change) --optional prompt to show how quickly day/night is changing end time2 = GetTimer(e) if fogon == 1 then SetFogNearest(change * 100) SetFogDistance(change * 400) end if fogcolour == 1 then SetFogRed(0) SetFogGreen(0) SetFogBlue(0) end if ambi == 1 then SetAmbienceIntensity(change) end SetAmbienceRed(change) SetAmbienceGreen(change) SetAmbienceBlue(change) SetSurfaceRed(change) SetSurfaceGreen(change) SetSurfaceBlue(change) if time1 + cycle_time < time2 then time1 = GetTimer(e) if daytime == 0 then if change == 0 then daytime = 1 else change = change - 1 end end if daytime == 1 then if change == 100 then daytime = 0 else change = change + 1 end end end end
--Simple Trap script -- Script will repeat infinitely so trap should continue to move back and fowards local playing = 0 function trap_simple_01_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); -- Move entity forward by 1000 units --MoveForward(e,1000) -- Move entity backwards by 1000 units --MoveBackward(e,1000) -- Start the if statement, only if the statement is true will the code under it run -- In this case if player is closer then 100 units then statement is true if PlayerDist < 100 then if playing == 0 then -- Tell reloaded to play sound 0 that we put on the entity LoopSound(e,0) playing = 1 end --Adds player health from the FPE file in this case -100 health -- Note at the moment player cannot dies from damage this way AddPlayerHealth(e); --End the if statement else playing = 0 StopSound(e,0) end --End the function end
--Simple Trap script -- Script will repeat infinitely so trap should continue to move back and fowards local playing = 0 function trap_simple_01_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); -- Move entity forward by 1000 units MoveForward(e,1000) -- Move entity backwards by 1000 units MoveBackward(e,1000) -- Start the if statement, only if the statement is true will the code under it run -- In this case if player is closer then 100 units then statement is true if PlayerDist < 100 then if playing == 0 then -- Tell reloaded to play sound 0 that we put on the entity PlaySound(e,0) playing = 1 --Adds player health from the FPE file in this case -100 health -- Note at the moment player cannot dies from damage this way AddPlayerHealth(e); end --End the if statement else playing = 0 StopSound(e,0) end --End the function end
--Simple Trap script -- Script will repeat infinitely so trap should continue to move back and fowards --distance for trap to travel over local movetrap = 100 --speed at which trap will "travel/move" local speed = 4 --set to 1 to move forward first / 0 to move backwards first local movetrapforward = 1 --set to amount of damage you want the trap to do local damage = 100 ------ local playing = 0 if movetrapforward == 1 then local moved = 0 else local moved = movetrap end movetrap = movetrap / speed ------ function trap_simple_01_main(e) PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); -- Move entity backwards by 1 units if movetrapforward == 0 then MoveBackward(e,speed) moved = moved - 1 end --check trap has reached end and tell it to move forwards if moved == 0 then movetrapforward = 1 end -- Move entity forward by 1 units if movetrapforward == 1 then MoveForward(e,speed) moved = moved + 1 end --check trap has reached end and tell it to move backwards if moved == movetrap then movetrapforward = 0 end --optional prompt to show distance --Prompt(moved) -- Start the if statement, only if the statement is true will the code under it run -- In this case if player is closer then 100 units then statement is true if PlayerDist < 100 then if playing == 0 then -- Tell reloaded to play sound 0 that we put on the entity PlaySound(e,0) playing = 1 --do damage to player HurtPlayer(e,damage); end --End the if statement else playing = 0 StopSound(e,0) end --End the function end
Login to post a reply