Value of a counter

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!
Faerghail
Posts: 72
Joined: Tue Mar 27, 2012 8:49 pm

Value of a counter

Post by Faerghail »

Hi all,

What is the new method to return the value of a counter ? old one was for example : counter1:getvalue()

I would like , to test a script , to print the value of counter1

Faerghail
User avatar
Skuggasveinn
Posts: 562
Joined: Wed Sep 26, 2012 5:28 pm

Re: Value of a counter

Post by Skuggasveinn »

Code: Select all

function firetrappuzzle1()

	local count1 = firecounter_1.counter:getValue()
	local count2 = firecounter_2.counter:getValue()
	local count3 = firecounter_3.counter:getValue()

	if firecounter_1.counter:getValue() == 0 and
	firecounter_2.counter:getValue() == 1 and
	firecounter_3.counter:getValue() == 0 then

	hudPrint("firecounter_1 has "..count1.." in value")
	hudPrint("firecounter_2 has "..count2.." in value")
	hudPrint("firecounter_3 has "..count3.." in value")
	mine_door_spear_1.door:open()

	else
	mine_door_spear_1.door:close()
	hudPrint("firecounter_1 has "..count1.." in value")
	hudPrint("firecounter_2 has "..count2.." in value")
	hudPrint("firecounter_3 has "..count3.." in value")
	end
	
end
Link to all my LoG 2 assets on Nexus.
Link to all my LoG 1 assets on Nexus.
Faerghail
Posts: 72
Joined: Tue Mar 27, 2012 8:49 pm

Re: Value of a counter

Post by Faerghail »

Great ,thank you for your quick answer :)
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Value of a counter

Post by Mysterious »

Hi. Hey Skuggs I like the coding. How would I use it with plates or levers etc.., if you don't mind thxs :)
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Value of a counter

Post by Doridion »

Skuggasveinn, I seen your part 7 of your tuto, and ... wow ^^

However , in case of a countdown ( never thinked to use the " Boss bar " to give a visual indication of the time , good tip), except by the hudprint ( Given only on the left -down screen corner ) , is there any solution to display something like a stopwatch ?

For example, entering in part of the dungeon, doing some puzzles, accessing to THE object ... but ... when taking it, begins a global CD with an alert message ... before all the dungeon parts will close/explose/disrupt/etc.

Love to stress players :D
User avatar
SnowyOwl47
Posts: 148
Joined: Fri Sep 12, 2014 10:41 pm

Re: Value of a counter

Post by SnowyOwl47 »

@Doridion and @Mysterious You guys have some more questions but skuggs is not here right now he might be offline any way.

first thing:

@Mysterious What you want to do is the below:

Code: Select all

lever.lever:getValue()

Code: Select all

plate.floortigger:getValue()
Now I could be wrong but that should do it!

But just remember to replace lever.lever with your levers name.lever so lever_name.lever and so on.

Second thing:

@Doridion There is nothing you can use like a stopwatch the players will see you can use hudPrints though:

Code: Select all

function time(time)
     while time == false do 
           hudPrint(time)
     end
end
function timer()
      script_entity.script.time(10)
end
Now that is kinda a blob and would need to be worked on a lot but its still something!
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Value of a counter

Post by JohnWordsworth »

Assuming there is a method like the old "onDrawGui" available for the party component (or another, new, component) then having a count down timer in the corner of the screen will be trivial. :).
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Value of a counter

Post by Doridion »

Thanks for your answer SnowyOwl47 ^^ I thinked about a script like that, just sad that we've not yet more informations about script and assets references :p I'll certainly script light modifications for torchs ( pulsing red for example ) and the boss count. For the message, he'll come after.

@John : Not sure ; spawning a CD centered up of the screen and seeing seconds/milliseconds growing down is stress-up, and stress is good for a quality game :D ( I completly assume to be a torturer )
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Value of a counter

Post by Mysterious »

As Doridion said thxs again for the help SnowyOwl47 :) It's really good to have some help. Looking forward to more of your Scripts and other things.
User avatar
Halluinoid
Posts: 165
Joined: Tue Apr 02, 2013 7:08 pm
Contact:

Re: Value of a counter

Post by Halluinoid »

do you have to use coding to get the counter to work?

I placed a counter with a value of 3 next to a passageway

in the passageway is a floor trigger

I connected the floor trigger to the counter

I then connected the counter with a value of 3 to the corridor door

I expected the counter to open the door after the floor trigger had sent 3 counts to the counter but no, the door remains closed :(
Post Reply