how do I "use" GrimTK Gui assets?

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
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

how do I "use" GrimTK Gui assets?

Post by FeMaiden »

I downloaded wordsworth's GUI toolkit for making dialogue options in my mod, but he left absolutely no instructions on how to use it...and apparently I'm the only noob thats too dumb to figure it out.

all the readme says is to place the file into my mod folder, than import the init.lua file

and then from inside my dungeon there is a GrimTK lua scripting entity I can place anywhwere in my mod and BAM I can use the tools.

I did all this, I placed the GrimTK entity in my mod but...

how do I access the tools? how do I use this to create dialogue?

what commands do I use? the syntax?

what I am most interested in is this

*from the description*

"
- Info Box: A box that pops up in the middle of the screen for a given amount of time. A fancy replacement for HUD Prints.
"
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: how do I "use" GrimTK Gui assets?

Post by Drakkan »

download the asset, open example dungeon and check how it is done - concept is trivial even for coding newbies like us. Perhaps you are just confused that in example dungeons are the scripts placed externally in the folders, not in script objects directly, so you have to open it from correct folder regarding what you want check. Then you can just copy this, place into your script object and change it as you want.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: how do I "use" GrimTK Gui assets?

Post by FeMaiden »

yeah, as usualy I jumped here too quickly crying out for help. I just found the example dungeon. thanks for responding though

I could actually inplement the "info box" with minimal coding... basically just chainging all my hudPrints to

Code: Select all

GTKGui.Basic.showInfoMessage(text, duration) 
I'm still gonna have to use getChampionByOrdinal to get the names of the characters to appear but I might be able to make this work in my mod
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: how do I "use" GrimTK Gui assets?

Post by cromcrom »

Grim TK is amazingly nice. I use it extensively, And still discover some features...
A trip of a thousand leagues starts with a step.
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: how do I "use" GrimTK Gui assets?

Post by FeMaiden »

I'm having a problem here.

I don't know what I did wrong.

I instaled this grimtk tools in my "practice dungeon"
it's a 1 room mod I use for testing scripts before I put them into my mod.

I put the ext/grimtk folder into my mod_assets and
then In my init.lua I added

Code: Select all

import "mod_assets/ext/grimtk/init.lua
and then I placed the grimtk script entity just like it told me.

and it works perfectly.....in my practice mod.


when I did the exact same step to install grimtk into my main project .
I did the same thing, i put the folder in my mod assets, added the line to init.lua, placed the script entity.

and then I copy pasted the exact code I wrote in my practice mod into my main mod and when I run it,

when it reaches this line

Code: Select all

GTKGui.Basic.dismissMessageBox();
the script stops, and I get an error message "attempt to call field 'dismissMessageBox' a nil value x"

now I thought it usually does this when it does not recognize the command i.e. if I have a typo in there.

but the command works perfectly in my practice mod, but not in my main mod. I even attempted to go through the steps 3 times, removing the folder, putting it back in, removing the line in the init.lua, putting it back and it just refuses to work
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: how do I "use" GrimTK Gui assets?

Post by cromcrom »

Weird. I had troubles with grimTK, until in the grimTK init, I rewrote these lines like this:

Code: Select all

					gtk.script:loadFile("mod_assets/ext/grimtk/scripts/hook.lua");
					gtk:createComponent("Script", "Constants"):loadFile("mod_assets/ext/grimtk/scripts/gtk/constants.lua");
					gtk:createComponent("Script", "Input"):loadFile("mod_assets/ext/grimtk/scripts/gtk/input.lua");					
					gtk:createComponent("Script", "Core"):loadFile("mod_assets/ext/grimtk/scripts/gtk/core.lua");
					gtk:createComponent("Script", "Widgets"):loadFile("mod_assets/ext/grimtk/scripts/gtk/widgets.lua");
Make sure the loadFile aims to the proper folders.
Except from that, I can't help you, it seems.
A trip of a thousand leagues starts with a step.
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: how do I "use" GrimTK Gui assets?

Post by FeMaiden »

cromcrom wrote:Weird. I had troubles with grimTK, until in the grimTK init, I rewrote these lines like this:

Code: Select all

					gtk.script:loadFile("mod_assets/ext/grimtk/scripts/hook.lua");
					gtk:createComponent("Script", "Constants"):loadFile("mod_assets/ext/grimtk/scripts/gtk/constants.lua");
					gtk:createComponent("Script", "Input"):loadFile("mod_assets/ext/grimtk/scripts/gtk/input.lua");					
					gtk:createComponent("Script", "Core"):loadFile("mod_assets/ext/grimtk/scripts/gtk/core.lua");
					gtk:createComponent("Script", "Widgets"):loadFile("mod_assets/ext/grimtk/scripts/gtk/widgets.lua");
Make sure the loadFile aims to the proper folders.
Except from that, I can't help you, it seems.

Code: Select all

               gtk.script:loadFile("mod_assets/ext/grimtk/scripts/hook.lua");
					gtk:createComponent("Script", "Constants"):loadFile("mod_assets/ext/grimtk/scripts/gtk/constants.lua");
					gtk:createComponent("Script", "Input"):loadFile("mod_assets/ext/grimtk/scripts/gtk/input.lua");					
					gtk:createComponent("Script", "Core"):loadFile("mod_assets/ext/grimtk/scripts/gtk/core.lua");
					gtk:createComponent("Script", "Widgets"):loadFile("mod_assets/ext/grimtk/scripts/gtk/widgets.lua");
well, this is what I see in the grim tk init.lua. it looks exactly like yours, unless there's something i'm not seeing.

this works perfectly in my 3 other mods, but not in my main project.

could it be that I added some custom item definitions and custom monster defintions?
and a few custom ambient tracks.
I did not mess with party hooks at all.

the only other difference I can think of is that I imported the beds and tables from Germanny's assets into my mod.

could something I did be causing compatibility issues?

the grimtk scripting entity does appear in my mod and I placed it on the map just like i was supposed to but the editor refuses to recognize both the

showMessageBox and the dismissMessageBox commands. it's as if I never installed the tools at all
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: how do I "use" GrimTK Gui assets?

Post by JohnWordsworth »

A few things to check...

1. When you place the script entity "grimtk" you must NOT call it "GTK" in the game. There must also not be any other entity in your dungeon simply called "GTK". I'll see if I can add a warning about this to the next release.

2. Are you using jKos' hook framework? If you are, I think you should include that first instead of last. Also, try moving the "import 'ext/grimtk/init.lua'" line around to the top/bottom of your init.lua file to see if that helps.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: how do I "use" GrimTK Gui assets?

Post by FeMaiden »

JohnWordsworth wrote:A few things to check...

1. When you place the script entity "grimtk" you must NOT call it "GTK" in the game. There must also not be any other entity in your dungeon simply called "GTK". I'll see if I can add a warning about this to the next release.

2. Are you using jKos' hook framework? If you are, I think you should include that first instead of last. Also, try moving the "import 'ext/grimtk/init.lua'" line around to the top/bottom of your init.lua file to see if that helps.
I am not using jkos hook framwork. in my main project. all I did was add some custom item definitions to my items. I added some custom sounds and ambient tracks. I copy pasted the fighter class 4 times and and changed the names to create 4 "new classes" and gave them different health and energy growth rates.

the only other thing I messed with was I installed the beds and tables from Germanny's asset pack.

I did not change the name of the grimtk script entiry, all I did was choose it from the asset list and place the object on my map.

this works on a brand new project but it does not work in my main project.

I realize this could be frustrating to you as well, because you don't know what I did in my mod. the only way would be for me to share my project and let you download it and see what it looks like. but my project...I don't know how disorganized or sloppy it is compared to other peoples mods. I have all my scripts placed and written in a logical way that make sense to me, but i seem to be on a different wavelength from other people
User avatar
FeMaiden
Posts: 290
Joined: Wed Jan 16, 2013 8:16 am

Re: how do I "use" GrimTK Gui assets?

Post by FeMaiden »

here is an example.
I went into the sample dungeon to find the script for the message box.
it had a link to the messagebox_demo_1.lua

I copied the code in there

Code: Select all

function messageBoxCallback(buttonText)
	hudPrint("You pressed: " .. buttonText);
end

function showMessageBox()
	local title = "A Message Box";
	local text = "A small message box invoked using:\n\nGTKGui.Basic.showMessageBox(title, text, callback, {'Okay', 'Cancel'}, 'small');";
	local okButton = "Okay";
	local cancelButton = "Cancel";
	
	GTKGui.Basic.showMessageBox(title, text, self.go.id..".script.messageBoxCallback", {okButton, cancelButton}, "small");
end


function dismissMessageBox()
	GTKGui.Basic.dismissMessageBox();
end

I create a brand new project named "practice dungeon". placed the grimtk script entiry.
then i placed a regular script entiry, pasted that code in it. put a floor trigger and connected it.

and it works.


but then I open my "horror themed" dungeon
placed the grimtk script entity

placed a regular script entity,
pasted the same exact code from my clipboard into it.

I press play and get

at this line

Code: Select all


	
	GTKGui.Basic.showMessageBox(title, text, self.go.id..".script.messageBoxCallback", {okButton, cancelButton}, "small");

it says attempt to call field 'showMessageBox' (a nil value)
Post Reply