clicking on a wall

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
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

clicking on a wall

Post by KhrougH »

i would like that something happens when you click on a wall... every wall!!!
an example could be:
imagine having a brush, the brush is onMouse, than you click on the wall so you can paint it... so when you click on the wall a script starts for changing the wall (for example)
or maybe it could be starting from the brush on a champion's hand. when you click on the hand hanging the brush the script starts for painting the wall.
but the point is that doesn't matter where you are... every wall in every level should be "paintable".
so i tried using "clickable" on walls so when you click on them... bla bla bla.
it didn't work. i don't think walls are clickable or maybe i made something wrong (as usual). it was something like:
SpoilerShow

Code: Select all

for level = 1, Dungeon:getMaxLevels() do
	for obj in Dungeon.getMap(level):allEntities() do 
		if obj.wall then
			obj.wall.clickable:addConnector(here,there,now)
		end	
	end
end
maybe walls are not defined as "wall" , maybe i have to define every wall as clickable into the defineObject... which is impossible, by the way.

does anyone can help?
[...]
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: clicking on a wall

Post by Pompidom »

I use wall_button_no_sound. This makes everything basically "clickable" and "interactive"

The "click" hitbox is large. Sound is disabled.
It's basically a wall_button with the model disabled.

Check Bongo's old asset pack.
Last edited by Pompidom on Mon Oct 22, 2018 9:46 pm, edited 1 time in total.
User avatar
THOM
Posts: 1266
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: clicking on a wall

Post by THOM »

Pompidom, I think it's no bigger problem to create an invisible and silent button - but AFAIK there is no way to add it to a wall-tileset.

So that would mean, that you would have to add this button manually on all walls (if you want that behaviour an EVERY wall). Really great effort...

Sadly I also have no other idea to solve this.

EDIT maybe you can create such button and attach it to all walls in the tilset definition by using auto decoration. Maybe you can experiment a bit with that...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Pompidom
Posts: 497
Joined: Sun May 06, 2018 9:42 pm

Re: clicking on a wall

Post by Pompidom »

I use the button for everything :)

Got some plants/moss on a wall? click it, *poof* the plants/moss are gone, unveiling a secret button.
Click on something hanging from a chain? it now starts spinning around slowly.
Click on a door or window? The door/window now opens.
Click on a tree? Some Horned fruit will drop from the tree or a branch, so you can craft a campfire.
Click on something interesting? You will get a hudprint with additional info about the object or a hint

Basically acting as the "look at" button from oldschool rpg's
The possibilities are endless :)
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: clicking on a wall

Post by KhrougH »

no worries, guys, i solved this problem by myself, thanks to Isaac help
here is the defineObjet about a general object you have to use. let's stay on the example. so a brush to paint a wall:
SpoilerShow

Code: Select all

defineObject{
	name = "brush",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/env/brush.fbx",
			offset = vec(0, 0, -1.5),
		},
		{
			class = "Item",
			uiName = "Brush",
      gfxAtlas = "mod_assets/textures/brush_atlas.tga",
      gfxIndex = 26,
			impactSound = "impact_blunt",
			weight = 20,
			primaryAction = "paint",
			projectileRotationX = 0,
			projectileRotationY = 0,
			description = "It's a Brush, don't use on walls, Vandal!!!",
		},
		{
			class = "ItemAction",
			name = "paint",
			uiName = "Brush",
			cooldown = 4,
			onAttack = function(self, champion, slot)
				--THIS IS FOR WALLS ARE FACING YOU
				reit = 0
				local dx, dy = getForward(party.facing)
				for wal in party.map:entitiesAt(party.x, party.y) do
					if string.match(wal.name, "wall") then
						if wal.elevation == party.elevation and wal.facing == party.facing and reit == 0 then
							local ladx, lady = getForward(wal.facing)
							-- [PAINT FUNCTION HERE]
							reit = reit +1
						end
					end
				end
				--SOME ASSETS HAS WALLS YOU CAN SEE FROM BOTH SIDES SO THEY COULD STAY REVERSAL, NOT FACING YOU. SO...
				for wal in party.map:entitiesAt(party.x+dx, party.y+dy) do
					if string.match(wal.name, "wall") then
						if wal.elevation == party.elevation and wal.facing == (party.facing+2)%4 and reit == 0then
							-- [AGAIN PAINT FUNCTION HERE]
							reit = reit +1
						end
					end
				end
			end,
		},
	},
  placement = "floor",
	editorIcon = 666,
	tags = { "KrougH" },
}
it MOSTLY works...
problems are:
it desn't work on mine's walls and beach's walls... and .. .don't remember...

by the way i used almost the same defineObject than the Horn . at the beginning of the game, first Bossfighting. you stand in a circle of rocks and play the horn. in the same way you place in front of a wall and paint. i think you could use for every other idea like... :roll: using a magnifying glass on a leaf...
or... you know the tiny_rats??? using a wood for hitting them... :lol: :lol: :lol: should be funny!!!
imagine having a butterfly net, capturing fireflies in the forest than you can use them for making a lamp!!!

well, please let me know if you have a better way to compile this defineObject.

P.S. : errata corrige, i changed a bit the code. it was wrong. now it works good!
P.P.S: errata corrige 2, i found a problem with decorations on wall that has "wall" in their name. so it find 2 "walls" and he make the action 2 times. that's bad, so changed again.

still open to suggestions :)
[...]
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: clicking on a wall

Post by KhrougH »

Pompidom wrote: Mon Oct 22, 2018 9:55 pm I use the button for everything :)

Got some plants/moss on a wall? click it, *poof* the plants/moss are gone, unveiling a secret button.
Click on something hanging from a chain? it now starts spinning around slowly.
Click on a door or window? The door/window now opens.
Click on a tree? Some Horned fruit will drop from the tree or a branch, so you can craft a campfire.
Click on something interesting? You will get a hudprint with additional info about the object or a hint

Basically acting as the "look at" button from oldschool rpg's
The possibilities are endless :)
yes, that's oldschool enough, but i every object yuo add in the game makes thegame heavier and slowe (i guess).
and than you have to add this botton everywhere and connecting it on a script ...
following your exemple of shaking a tree (i will steal your idea, i like it ;) ). you should put a button every time you place a tree on the map and specially you have to placee 4 buttons and connecting to an entity script.

now, insted doing this, imagine define this tree as an object in an external script that you call from the init.lua . at this point all you need to do is just placing the tree. and than when you click on it camera shakes a litte and a brush sound come out and wirh a delayedCall also some (dandomly chosen) fruits falls from the tree. not only in front of the party but all around the tree.

in this way: no more buttons to pus,. no more arrows all over the map from the buttons to the entity_script, and when you load the DAT file it's way faster than a dungeon full of objects!

well, @Pompidom , that's just my opinion made in months of YOUR style. but now with Isaac help i'm learnng and understanding what define(ing)Object can really do. and now i would change all the work i did in 4 months of "trying" do something usefull.

what do you think about it??
[...]
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: clicking on a wall

Post by Pompidom »

Making things more efficient you say? Optimizing?

Unheard of!

Sounds more like the devil's talk!

Witchcraft! Herecy!

Torches and pitchforks! Burn the witch!

:lol:
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: clicking on a wall

Post by KhrougH »

:lol: :lol: :lol:
exactly!
but effetively, part of my problem (and maybe problem of many) is that i reached this idea when my "mod" was already at 5th level... so, changing now is not for eficiency, because , of corse, i have to RE-DO many things I already did and works good. but is a good school for learning how to compile in lua. today i downloaded a lua script editor on my mobile for learning and testing some ideas even on my trips to work and back :lol: :lol: :lol:
I must be crazy!!!

next step is learning how do model in 3d. :geek:
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: clicking on a wall

Post by Isaac »

KhrougH wrote: Thu Oct 25, 2018 8:46 pm ...next step is learning how do model in 3d. :geek:
https://www.youtube.com/watch?v=JYj6e-72RDs
https://www.youtube.com/watch?v=yi87Dap_WOc
User avatar
KhrougH
Posts: 68
Joined: Tue Sep 04, 2018 11:45 pm
Location: Roma

Re: clicking on a wall

Post by KhrougH »

i learned some Blender funcions and i made a simple object . first for exercise and secon because i needed for my map.
but it doesn't work!!! i did it 2 times: the first give me errors when i export it from blender as *.model
and the second give me error in LoG2 editor, when i place it on the map.
https://drive.google.com/open?id=1h0iIM ... YAcWSg-ooq
https://drive.google.com/open?id=1ozdhx ... Z0cqs9lQXO

here is the (horrible) asset:
https://drive.google.com/open?id=1NrxOT ... DIJs4A9UD4
what's wrong with it?

please help :cry: :cry: :cry:
[...]
All those moments will be lost in time, like tears in rain.
Time to die.
Post Reply