Scripting ideas for moving boulder

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
danco
Posts: 5
Joined: Fri Jun 07, 2013 11:37 am

Scripting ideas for moving boulder

Post by danco »

Hi.

I am experimenting with a rolling boulder (Indiana Jones)
I've downloaded the files needed http://grimrock.nexusmods.com/mods/176/ ... D176&pUp=1

And I have gotten the boulder to roll north in my dungeon.


The problem I am having is that I can't trigger the script.
It triggers itself automaticly and I have no clue what to do. (Meaning that it triggers the second I start the dungeon preview in editor mode)

I have this script in game;
name: script_entity
ID: boulderScript
function launchBoulders()
launchBoulderNorth()
launchBoulderWest()
launchBoulderSouth()
launchBoulderEast()
local boulder_sound_timer = findEntity("boulder_sound_timer")
if boulder_sound_timer == nil then
local boulder_sound_timer = spawn("timer", party.level, party.x, party.y, party.facing, "boulder_sound_timer")
boulder_sound_timer:addConnector("activate", "boulder_script", "doBoulderSounds")
boulder_sound_timer:setTimerInterval(1)
boulder_sound_timer:activate()
end
end

function launchBoulderNorth()
shootProjectile("boulder",1,15,27,0, 3,0,0,0,0,0,1000,nil,true)
end
function launchBoulderWest()
shootProjectile("boulder",1,10,4,3, 3,0,0,0,0,0,1000,nil,true)
end
function launchBoulderSouth()
shootProjectile("boulder",1,2,4,2, 3,0,0,0,0,0,1000,nil,true)
end
function launchBoulderEast()
shootProjectile("boulder",1,2,10,1, 3,0,0,0,0,0,1000,nil,true)
end

function doBoulderSounds()
for i in allEntities(party.level) do
if i.name == "boulder" then
checkDistanceFromParty(i)
end
end
end

function checkDistanceFromParty(boulder)
local distance = math.floor(math.sqrt (math.pow(party.x - boulder.x,2) + math.pow(party.y - boulder.y,2)))
--print("boulder distance"..distance.."")
if distance <= 1 then
party:shakeCamera(.05, 2)
party:playScreenEffect("earthquake_dust")
playSoundAt("boulder_rolling", party.level, boulder.x, boulder.y)
elseif distance <= 2 then
party:shakeCamera(.04, 2)
party:playScreenEffect("earthquake_dust")
playSoundAt("boulder_rolling", party.level, boulder.x, boulder.y)
elseif distance <= 3 then
party:shakeCamera(.03, 2)
party:playScreenEffect("earthquake_dust")
playSoundAt("boulder_rolling", party.level, boulder.x, boulder.y)
elseif distance <= 4 then
party:shakeCamera(.02, 2)
party:playScreenEffect("earthquake_dust")
playSoundAt("boulder_rolling", party.level, boulder.x, boulder.y)
elseif distance <= 5 then
party:shakeCamera(.01, 2)
party:playScreenEffect("earthquake_dust")
playSoundAt("boulder_rolling", party.level, boulder.x, boulder.y)
end
end


After I added that I had to create a trigger-script.

Name: script_entity
ID: test
boulderScript:launchBoulderNorth()

Now every time I start the dungeon it launches the boulder.
I would like to have a hidded pressure plate trigger the "launch boulder" script so that it waits for the correct moment.


Does anyone know how to delay that script to a certain point in time, and prevent it from launching emidietly?



Thanks guys
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripting ideas for moving boulder

Post by Komag »

You need to have the launch command in a function, then you can connect to the function with a plate or whatever
Finished Dungeons - complete mods to play
User avatar
AdrTru
Posts: 223
Joined: Sat Jan 19, 2013 10:10 pm
Location: Trutnov, Czech Republic

Re: Scripting ideas for moving boulder

Post by AdrTru »

Hi,
try to look in my scripts in aplications on this boulder.
http://grimrock.nexusmods.com/mods/220/?
My LOG2 projects: virtual money, Forge recipes, liquid potions and
MultiAlcoveManager, Toolbox, Graphic text,
danco
Posts: 5
Joined: Fri Jun 07, 2013 11:37 am

Re: Scripting ideas for moving boulder

Post by danco »

Thanks a lot guys!
Post Reply