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!
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

Code: Select all

defineObject{
	name = "ud_roof_01_inverted",
	baseObject = "base_wall_decoration",
	components = {
		{
			class = "Model",
			model = "mod_assets/vb_models/models_under_d/env/ud_roof_01.fbx",
			staticShadow = true,
                        rotation = vec(180, 0, 0),
		},
	},
	replacesWall = true,
	tags = { "VB","Under Dungeon" },
}
So basically this, what I asked in the first place :)

Worx great! Thanks Thom!
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

hello again :)
i have two help needs in one question:
how can i "use" global tables?
i'm defining an object and i want to have many on them on the map but i want the player can use it only one time each object. than i tried with a table, but i can't find a way to use as global table. i did this:
SpoilerShow

Code: Select all

local mytable = {}

defineObject{
	name = "myobject",
	baseObject = "base_mybase",
	components = {
	bla bla bla...
	{
			class = "Clickable",
			offset = vec(0, 1, -3),
			size = vec(5, 5, 0),
			maxDistance = 2,
			frontFacing = false,
			--debugDraw = true,
			onClick = function(self)
        local allow = true
        for _, v in ipairs(mytable) do
          if v == self.go.id then
            allow = false
            break
          else
            allow = true
          end
        end
        if allow == true then
          table.insert(mytable,self.go.id)
          playSound("secret")
          party.party:shakeCamera(0.02,2)
          hudPrint("hurray")
          end
        end
      end,
		},
	
it works good, but of corse, "local" is not global. so if i use all of them than i save the game and than i load the game and i use them again they still works. but they shouldn't.
so. how can i solve this problem? maybe with a "disableself" component!?

second question is:
how can i do the same thing but insted using myobject only one time, i want to use it once in a day?
so after 24 hours (game timing) i can use it again.

i hope i've been clear :?
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

how can i make an object clickable on every side in defineObject?
like a rock. i would like that something happens whenever you stand around it not only in "facing" position.
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
User avatar
THOM
Posts: 1267
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

KhrougH wrote: Tue Nov 13, 2018 3:10 pm how can i make an object clickable on every side in defineObject?
like a rock. i would like that something happens whenever you stand around it not only in "facing" position.
Have a look how it's done with the "pushable block" object: there are four klickable zones on every side.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

THOM wrote: Tue Nov 13, 2018 4:54 pm
KhrougH wrote: Tue Nov 13, 2018 3:10 pm how can i make an object clickable on every side in defineObject?
like a rock. i would like that something happens whenever you stand around it not only in "facing" position.
Have a look how it's done with the "pushable block" object: there are four klickable zones on every side.
gosh, you're right!!!
i'll take a look, thanks
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

ok, i already checked this argument on this forum and i couldn't find the right thread, so i have a brand new (annoying) question:
i'm working with blender. doing a tree. it works fine. but looks what happens when i use it in the game:
https://drive.google.com/open?id=1Pgisq ... UfAcLiK9XS
https://drive.google.com/open?id=1I4cgb ... 6XFl56CpY-
https://drive.google.com/open?id=1woHjq ... X-ISdYzt2b
https://drive.google.com/open?id=1Q8Rtp ... ue0qvcXNvt
walking back from the tree, it disappear. it doesn't happens to an already existing tree in game.
as you can see from the screenshots stepping away it vanish ... like a cheap magic! :lol:
i made copy/paste of defineObject and defineMaterial of the inGame tree. so it should be something in Blender. but i can't find the solution.
somebody knows what's going on in there?
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: Ask a simple question, get a simple answer

Post by KhrougH »

few days ago i asked this:
KhrougH wrote: Tue Nov 13, 2018 2:47 pm hello again :)
i have two help needs in one question:
how can i "use" global tables?
i'm defining an object and i want to have many on them on the map but i want the player can use it only one time each object. than i tried with a table, but i can't find a way to use as global table. i did this:
SpoilerShow

Code: Select all

local mytable = {}

defineObject{
	name = "myobject",
	baseObject = "base_mybase",
	components = {
	bla bla bla...
	{
			class = "Clickable",
			offset = vec(0, 1, -3),
			size = vec(5, 5, 0),
			maxDistance = 2,
			frontFacing = false,
			--debugDraw = true,
			onClick = function(self)
        local allow = true
        for _, v in ipairs(mytable) do
          if v == self.go.id then
            allow = false
            break
          else
            allow = true
          end
        end
        if allow == true then
          table.insert(mytable,self.go.id)
          playSound("secret")
          party.party:shakeCamera(0.02,2)
          hudPrint("hurray")
          end
        end
      end,
		},
	
it works good, but of corse, "local" is not global. so if i use all of them than i save the game and than i load the game and i use them again they still works. but they shouldn't.
so. how can i solve this problem? maybe with a "disableself" component!?

second question is:
how can i do the same thing but insted using myobject only one time, i want to use it once in a day?
so after 24 hours (game timing) i can use it again.

i hope i've been clear :?
i found this thread: viewtopic.php?f=22&t=8147#p82429

is this my answer?
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: Ask a simple question, get a simple answer

Post by Pompidom »

KhrougH wrote: Thu Nov 15, 2018 5:27 pm ok, i already checked this argument on this forum and i couldn't find the right thread, so i have a brand new (annoying) question:
i'm working with blender. doing a tree. it works fine. but looks what happens when i use it in the game:
https://drive.google.com/open?id=1Pgisq ... UfAcLiK9XS
https://drive.google.com/open?id=1I4cgb ... 6XFl56CpY-
https://drive.google.com/open?id=1woHjq ... X-ISdYzt2b
https://drive.google.com/open?id=1Q8Rtp ... ue0qvcXNvt
walking back from the tree, it disappear. it doesn't happens to an already existing tree in game.
as you can see from the screenshots stepping away it vanish ... like a cheap magic! :lol:
i made copy/paste of defineObject and defineMaterial of the inGame tree. so it should be something in Blender. but i can't find the solution.
somebody knows what's going on in there?
dissolveStart = 4,
dissolveEnd = 6,

this is apparently the default settings

add this to your defineobject and increase the numbers
minmay
Posts: 2770
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

dissolveStart and dissolveEnd are nil by default. If your model has a mesh node called lod1_mesh, it will start to fade in at a distance from the camera equal to dissolveStart*3 meters, and finish fading in at dissolveEnd*3 meters. Meanwhile, the rest of the mesh nodes will fade out.

So there are two ways it is typically used: to switch to a lower-detail mesh at long distances (used for the vanilla game's trees), and to disappear completely at long distances (used for the vanilla game's grass, heather, etc.). If you want neither, leave dissolveStart and dissolveEnd nil, and no fading will occur.
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
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Ask a simple question, get a simple answer

Post by akroma222 »

KhrougH wrote: Tue Nov 13, 2018 2:47 pm hello again :)
i have two help needs in one question:
how can i "use" global tables?
i'm defining an object and i want to have many on them on the map but i want the player can use it only one time each object. than i tried with a table, but i can't find a way to use as global table. i did this:
SpoilerShow

Code: Select all

local mytable = {}

defineObject{
	name = "myobject",
	baseObject = "base_mybase",
	components = {
	bla bla bla...
	{
			class = "Clickable",
			offset = vec(0, 1, -3),
			size = vec(5, 5, 0),
			maxDistance = 2,
			frontFacing = false,
			--debugDraw = true,
			onClick = function(self)
        local allow = true
        for _, v in ipairs(mytable) do
          if v == self.go.id then
            allow = false
            break
          else
            allow = true
          end
        end
        if allow == true then
          table.insert(mytable,self.go.id)
          playSound("secret")
          party.party:shakeCamera(0.02,2)
          hudPrint("hurray")
          end
        end
      end,
		},
	
it works good, but of corse, "local" is not global. so if i use all of them than i save the game and than i load the game and i use them again they still works. but they shouldn't.
so. how can i solve this problem? maybe with a "disableself" component!?

second question is:
how can i do the same thing but insted using myobject only one time, i want to use it once in a day?
so after 24 hours (game timing) i can use it again.

i hope i've been clear :?
Hey KhrougH,

It's an extremelyuseful thread indeed .... and
Here is a detailed answer to your local / global table Q (minmays response at the end)
viewtopic.php?f=22&t=18236&p=116703&hil ... ig#p116703
And further explanations / examples in .rhavin 's thread (answers provided by Isaac & minmay)
viewtopic.php?f=22&t=18159&p=115633&hil ... ig#p115637

Searching the forum for "Config" will set you on the right track ;)
(And Config. is how I usually ref global tables - but do read into it as it is not as simple at that)

Enjoy & happy reading! 8-)
Last edited by akroma222 on Fri Nov 16, 2018 7:35 pm, edited 2 times in total.
Post Reply