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!
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Modraneth wrote: Mon Mar 09, 2020 9:22 pm i want to make it possible to get some food, but not overdoing it.. so i would need a stopper or a timer
how many time should be good to no overdoing it and make it functional ?

EDIT: also can someone send me a link to the main campaign editor file ?
In the editor, in the Spawner object properties, you can set a value for the cooldown. It starts ticking after activation. If the spawner gets activated again, before the cooldown expires, then that activation gets ignored.

If this has nothing to do with any puzzle, or aesthetic, but just needs to replenish the fish, then just connect a timer to the spawner, and set it for twenty minutes, to an hour or so. There are other ways, of course. It could be scripted to count the steps that the party takes. It could be scripted to count the fish, and respawn when they are all missing, or are too few. It could be scripted to respawn when they leave the level (using the cooldown to prevent exploit).

If you have many spawners like this, it would be better to set the timer to call a script function that activates them all; even better if it activates only some of them, and/or in staggered delay, so that they don't all pop into view at once.
_____________

As for the campaign file, the game installs the files; you have them already. Make a new editor project. Call it what you like; or name it Grimrock2. Then open the project file in a text editor, and change the contents to this:

Code: Select all

-- This file has been generated by Dungeon Editor 2.2.4

dungeonName "Grimrock 2"
author "Almost Human"
description "The official campaign"
dungeonFolder "assets/dungeons/grimrock2"


Then reload the project. You cannot save any changes to this project; it won't work.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote: Tue Mar 10, 2020 1:15 amIf this has nothing to do with any puzzle, or aesthetic, but just needs to replenish the fish, then just connect a timer to the spawner, and set it for twenty minutes, to an hour or so.
Keep in mind that TimerComponent runs slower when the party isn't on the same level as it, so depending on the use case, it may be better to attach the TimerComponent to the party or use delayedCall() instead.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Certainly so... but then I'd have to do it. :mrgreen:
[kidding]

@Modraneth
Any one of us here would gladly explain how to add a timer component to the party, or script a looped call of all the spawners; giving them variable delays.
User avatar
Modraneth
Posts: 95
Joined: Thu Aug 27, 2015 8:27 pm
Location: Portugal

Re: Ask a simple question, get a simple answer

Post by Modraneth »

well the way should probably be counting steps.
im thinking on only doing it in 1 or 2 places, like rivers or ocean.
how do i change the script from "rest" to "steps walked"?
Mods:
Isle of Gunger
The Bloody Path Dropped
A World of Power work in progress
User avatar
Eleven Warrior
Posts: 746
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Hi all.

How would I make a lock that goes onto Pillars rather than moving each locks position by script function.
I just wanna lock object the only goes onto pillars Ty for the solution to this :)
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Modraneth wrote: Wed Mar 11, 2020 8:58 pm well the way should probably be counting steps.
For some reason I had thought that party_steps was a game statistic; it might still be, but I can't find mention of it. Obviously if it is, then that's the best way to do it.

However, an easy alternative is to manually keep count. To count the steps, create a counter object; name it 'party_steps'.
You can then place this in a script_entity:

Code: Select all

party.party:addConnector('onMove', self.go.id, 'incrementSteps')

function incrementSteps(self, dir) 
	if party_steps then
		local Dx, Dy = getForward(dir)
		if not party.map:isBlocked(party.x+Dx, party.y+Dy, party.elevation) then
		  	party_steps.controller:increment() 	
		end
	else
		print("The function 'incrementSteps' requires a counter object (named 'party_steps') in order to work.")
	end		
end
The counter 'party_steps' will then hold the count of steps traveled by the party. You can check that value by calling
party_steps.counter:getValue() in your condition.
_________
Eleven Warrior wrote: Thu Mar 12, 2020 9:06 am How would I make a lock that goes onto Pillars rather than moving each locks position by script function.
To make a pillar lock asset, you define a new variation on the lock-type, and set the offsets in the onInit hook(s).

Approximately like this:

Code: Select all

onInit=function(self) self.go.model:setOffset(vec(-1.45,1.3,-.23)) end,
*Model offset shown, but this must be done for both the model, and the clickable components.

There is a caveat to this. The Grimrock games expect the party to be on the same tile as the lock when using the key. This means that the lock will only work if they are standing left side of a lock that is offset to the right, and vice versa.

** Here is a project map for this. It is not for a cut & paste, but rather it's to use as a tool to learn how to adjust the positions, and to quickly see your changes in the preview. You would then use these newly determined vector values in your defined locks.

https://www.dropbox.com/s/h8zsn3eon862f ... s.zip?dl=1
Image
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

Isaac wrote: Thu Mar 12, 2020 4:35 pm
Modraneth wrote: Wed Mar 11, 2020 8:58 pm well the way should probably be counting steps.
For some reason I had thought that party_steps was a game statistic; it might still be, but I can't find mention of it. Obviously if it is, then that's the best way to do it.
GameMode.getStatistic("tiles_moved")
User avatar
Modraneth
Posts: 95
Joined: Thu Aug 27, 2015 8:27 pm
Location: Portugal

Re: Ask a simple question, get a simple answer

Post by Modraneth »

thanks a lot.

other question, making an item spawn on a surface
like i place 1 item, that item disappear after 3 sec, (2s pause), another item spawn
lets say
surface-place fish-3s pause-fish disappear-2s pause-bread spawn

something like that
(i will change the items myself)
Mods:
Isle of Gunger
The Bloody Path Dropped
A World of Power work in progress
User avatar
Eleven Warrior
Posts: 746
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

Ty you for solviung the lock problem for me awesome bro :)
User avatar
Modraneth
Posts: 95
Joined: Thu Aug 27, 2015 8:27 pm
Location: Portugal

Re: Ask a simple question, get a simple answer

Post by Modraneth »

Modraneth wrote: Thu Mar 12, 2020 10:30 pm thanks a lot.

other question, making an item spawn on a surface
like i place 1 item, that item disappear after 3 sec, (2s pause), another item spawn
lets say
surface-place fish-3s pause-fish disappear-2s pause-bread spawn

something like that
(i will change the items myself)
aff almost made it work
but now the item disappears but the next item do not show up
where do I failed?

Code: Select all

function SpawnRewards()
  local s = Laurent_spot.surface
    for _,e in s:contents() do
      if e.go.name == "corga_amulet" then
        e.go:destroy()
	 spawn("fire_gauntlets", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
	end
	end
end
Mods:
Isle of Gunger
The Bloody Path Dropped
A World of Power work in progress
Post Reply