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!
Killcannon
Posts: 73
Joined: Sun Apr 12, 2015 2:57 pm

Re: Ask a simple question, get a simple answer

Post by Killcannon »

Zo Kath Ra wrote: Sat Jan 26, 2019 1:28 am Timer:
timerInterval = 5
triggerOnStart = true
currentLevelOnly = true

The timer is connected to a script that prints "test".

It should print "test" as soon as the game starts, but the first print happens after 5 seconds.
What am I doing wrong?
I may be wrong but when you set a timer with an interval, the timer starts at the interval set and will wait til the count down to trigger initially. If you want your hudprint to immediately trigger you must also include a 'run once' line along side the timer.
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 »

Call the command to start it. You can put it in the script to run at load. This works whether or not the timer is active [started].

Code: Select all

function test() print("test") end

timer_1.timer:start()
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

The dragon boss in the default campaign has text appearing in the middle of the screen.

How to make it happen?
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 »

You have to use the onDrawGui party hook for that.

PartyComponent.onDrawGui(self, context)

It must be defined it in the party object to become active—connectors by themselves don't work unless it's already defined.

Within the hook function you gain access to the graphics context object, and its many features; two of which are for drawing text.

https://github.com/JKos/log2doc/wiki/Ob ... icscontext

The concept here, is that within the onDrawGui hook function, you can issue drawing commands with the context object. This will draw on the current frame [only]. In practice, to actually see the drawing for more than a split second, you have to draw it for each frame. So arrange the drawing commands in the hook to render the text when it is called; as it is for each frame.

If you want to be able to start & stop the effect, then you need to enclose the drawing commands behind a condition; boolean true/false works well. That way it does not call the drawing commands when the condition is false.

You can set the font size via GraphicsContext.font("large")
—Known valid values for font are: "tiny", "small", "medium", "large"

Centering is not automatic, and will be different for different resolutions/and aspects. The context object does provide the screen dimensions with: context.width & context.height
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Mkay, I suppose I can scratch this feature off my list :)
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 »

Well... You asked "how". ;)

What [precisely] do you need?
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

No it's fine, I was simply hoping it would be something easy like "hudprint"
I wanted to use it for level transitions. It's not important.

It's one of those things, too much work for what it is :)

I understand your explanation, but I have no idea how to do it. So it's something I simply place on the backburner until I figure out how to do it myself or let someone do it for me :)

I wanted to do something like you find in most rpg's when transitioning to a new map/zone
The name of the map like for example "Fire Tower A1"or something like that
or "sayings" like "Into the Fray" or "Knee-deep in the dead"
"A sinister Turn" when you enter a map where you will be betrayed by some npc.
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 »

Try this:

Code: Select all

--Call this from a script, with the text you wish to be displayed. — script_entity_1.script.intro("Into the fray!")

function intro(text)
	GameMode.fadeOut(0x00000, 0)	
	if type(text) == "string" then
		party.party:rest(text)	
	end
end
Or

Code: Select all

--Place invisible floor triggers; each one connected to their own function that passes a unique message when triggered.

function intro(text)
	GameMode.fadeOut(0x00000, 0)	
	if type(text) == "string" then
		party.party:rest(text)	
	end
end

function map1()
	intro("Into the fray!")
end	

function map2()
	intro("The Black Crypt")
end	

function map3()
	intro("Swamp Tour")
end	
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Mh - this solution just works, if the party sleeps while the text pops up, right?

Can you change the size of the text?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
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 »

The one above? It forces a rest state with a caption; it fades when they move. It is possible (but complicates it) to have the function wake the party after a few seconds. I did have it that way for a while (using two different methods, a timer, and a delayedCall), but eventually removed the feature.
Post Reply