Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

paste the script you used to spawn them to make things easy
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

TheLastOrder wrote:Watching this tutorial:

https://www.youtube.com/watch?v=-YlAZwq ... Nc&index=7

It comes to my mind that somehow you need to stop the script once it has finished. Otherwise, the game crashes if you put BANE back into the altar and you pick it again, as long as the monster doesn't exist anymore...

Do I need a Boolean or something to stop that?
I tried this
dungeon_alcove_magma:destroy()
but the game crashes.

So the simple question is:

How to stop calls into scripts for BOSSFIGHTS that can't be triggered again?
do something like this:

Code: Select all

onlyOnce = false

function trap()
	if onlyOnce == false then
		onlyOnce = true
		--do stuff
	end
end
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Here's the script. The script itself can probably be compressed but this part of the script isn't an issue.

Code: Select all

function firstButton()
	dd_1.door:open()
	spawn("wall_button", 8, 11, 11, 2, 0, "button_1").clickable:addConnector("onClick", "script_entity_25", "secondButton")
	wall_button_7.clickable:disable()
	end	

function secondButton()
	dd_2.door:open()
	spawn("wall_button", 8, 5, 17, 3, 0, "button_2").clickable:addConnector("onClick", "script_entity_25", "thirdButton")
	button_1.clickable:disable()
	end
	
function thirdButton()
	dd_3.door:open()
	spawn("wall_button", 8, 22, 3, 3, 0, "button_3").clickable:addConnector("onClick", "script_entity_25", "fourthButton")
	button_2.clickable:disable()
	end
	
function fourthButton()
	dd_4.door:open()
	spawn("wall_button", 8, 7, 5, 2, -1, "button_4").clickable:addConnector("onClick", "script_entity_25", "fifthButton")
	button_3.clickable:disable()
	end
	
function fifthButton()
	dd_5.door:open()
	spawn("wall_button", 8, 1, 17, 1, 0, "button_5").clickable:addConnector("onClick", "script_entity_25", "sixthButton")
	button_4.clickable:disable()
	end

function sixthButton()
	dd_6.door:open()
	button_5.clickable:disable()
	end
Now, I want to be able to destroy any of these buttons at any time. I know it's something simple, but my brain just isn't working at the moment.

And thankyou for the quick reply from befor. :)
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

I see you have named them, so you can just do

Code: Select all

button_1:destroy()
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

It is a little more complicated however in the fact that each created button is on a central timer that resets every time a button is clicked. If the button isn't reached in time however that button (and any previous buttons) are destroyed.
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

GoldenShadowGS wrote:
TheLastOrder wrote:Watching this tutorial:

https://www.youtube.com/watch?v=-YlAZwq ... Nc&index=7

It comes to my mind that somehow you need to stop the script once it has finished. Otherwise, the game crashes if you put BANE back into the altar and you pick it again, as long as the monster doesn't exist anymore...

Do I need a Boolean or something to stop that?
I tried this
dungeon_alcove_magma:destroy()
but the game crashes.

So the simple question is:

How to stop calls into scripts for BOSSFIGHTS that can't be triggered again?
do something like this:

Code: Select all

onlyOnce = false

function trap()
	if onlyOnce == false then
		onlyOnce = true
		--do stuff
	end
end
Awesome, it works but I still have a problem: the countdown resets (the monster recovers all its health) if I place back an item and remove it while the countdown is in progress!

However, after the bossfight has ended, nothing happens in the alcove, so that´s one part solved!!

Thank you so much GoldenShadow.

Here is the script:

Code: Select all

onlyOnce = false

function startmagmacountdown()

	if onlyOnce == false then
	onlyOnce = true
    magma_countdown.bossfight:addMonster(magma_countdown_turtle.monster)
    magma_countdown.bossfight:activate()
    timer_magma.timer:start()
    dungeon_door_portcullis_9.door:close()
    party.party:shakeCamera(0.04,15)
    dungeon_fire_pit_1.particle:enable()
    dungeon_fire_pit_2.particle:enable()
    dungeon_fire_pit_3.particle:enable()
    dungeon_fire_pit_4.particle:enable()
    dungeon_fire_pit_5.particle:enable()
    dungeon_fire_pit_6.particle:enable()
    dungeon_fire_pit_7.particle:enable()

end

timecount = 1

function hurtturtle()

    if timecount == 1 then
    elseif timecount == 2 then
    elseif timecount == 3 then
    magma_countdown_turtle.monster:setHealth(95)
    elseif timecount == 4 then
    magma_countdown_turtle.monster:setHealth(90)
    elseif timecount == 5 then
    magma_countdown_turtle.monster:setHealth(85)
    elseif timecount == 6 then
    magma_countdown_turtle.monster:setHealth(80)
    elseif timecount == 7 then
    magma_countdown_turtle.monster:setHealth(75)
    elseif timecount == 8 then
    magma_countdown_turtle.monster:setHealth(70)
    elseif timecount == 9 then
    magma_countdown_turtle.monster:setHealth(65)
    elseif timecount == 10 then
    magma_countdown_turtle.monster:setHealth(60)
    elseif timecount == 11 then
    magma_countdown_turtle.monster:setHealth(55)
    elseif timecount == 12 then
    magma_countdown_turtle.monster:setHealth(50)
    elseif timecount == 13 then
    magma_countdown_turtle.monster:setHealth(45)
    elseif timecount == 14 then
    magma_countdown_turtle.monster:setHealth(40)
    elseif timecount == 15 then
    magma_countdown_turtle.monster:setHealth(35)
    elseif timecount == 16 then
    magma_countdown_turtle.monster:setHealth(30)
    elseif timecount == 17 then
    magma_countdown_turtle.monster:setHealth(25)
    elseif timecount == 18 then
    magma_countdown_turtle.monster:setHealth(20)
    elseif timecount == 19 then
    magma_countdown_turtle.monster:setHealth(15)
    elseif timecount == 20 then
    magma_countdown_turtle.monster:setHealth(10)
    elseif timecount == 21 then
    magma_countdown_turtle.monster:setHealth(5)
    elseif timecount == 22 then
    magma_countdown_turtle.monster:setHealth(0)

    elseif timecount == 23 then
    magma_countdown.bossfight:deactivate()
    magma_countdown_turtle.monster:die();
    die = true;
    timer_magma.timer:stop()

    spawn("flame_wave", 7, 27, 9, 1, 0)
    spawn("flame_wave", 7, 29, 9, 1, 0)
    spawn("flame_wave", 7, 27, 11, 1, 0)
    spawn("flame_wave", 7, 29, 11, 1, 0)
    spawn("flame_wave", 7, 27, 13, 1, 0)
    spawn("flame_wave", 7, 29, 13, 1, 0)
    spawn("flame_wave", 7, 28, 15, 1, 0)

    timecount = 1
    return
  end
    timecount = timecount + 1

end

function dontshakeitbaby()
    dungeon_fire_pit_1.particle:disable()
    dungeon_fire_pit_2.particle:disable()
    dungeon_fire_pit_3.particle:disable()
    dungeon_fire_pit_4.particle:disable()
    dungeon_fire_pit_5.particle:disable()
    dungeon_fire_pit_6.particle:disable()
    dungeon_fire_pit_7.particle:disable()

end

end
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

You can remove the connectors from the alcove.
Fill in the correct details and place this in the function somewhere

Code: Select all

   alcove_1.surface:removeConnector("onRemoveItem", "Script_entity_1", "function")
alcove_1 is whatever your alcove ID is named
"Script_entity_1" is what entity the connector is connected to
"function" is a script function, if targeting a script, or an action like "close" if its targeting a door. Just put here what the connector shows.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

I'm also trying to look for ways to destroy spawned buttons and levers without getting an invalid connector script warning. Is that even possible?

EDIT: Wait was my question just indirectly answered above? :lol:
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Grimfan wrote:It is a little more complicated however in the fact that each created button is on a central timer that resets every time a button is clicked. If the button isn't reached in time however that button (and any previous buttons) are destroyed.
So, what you want is a button that spawns another button. When the next button is pressed, it destroys the previous button, right?
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Ask a simple question, get a simple answer

Post by Grimfan »

Not quite. Each button is on a 30 second timer. If the button isn't pressed in time it and all previously spawned buttons are destroyed.
Post Reply