Page 1 of 3
clicking on a wall
Posted: Mon Oct 22, 2018 7:30 pm
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:
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?
Re: clicking on a wall
Posted: Mon Oct 22, 2018 9:28 pm
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.
Re: clicking on a wall
Posted: Mon Oct 22, 2018 9:42 pm
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...
Re: clicking on a wall
Posted: Mon Oct 22, 2018 9:55 pm
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
Re: clicking on a wall
Posted: Tue Oct 23, 2018 6:13 pm
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:
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...
using a magnifying glass on a leaf...
or... you know the tiny_rats??? using a wood for hitting them...
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
Re: clicking on a wall
Posted: Thu Oct 25, 2018 12:58 am
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??
Re: clicking on a wall
Posted: Thu Oct 25, 2018 11:17 am
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!
Re: clicking on a wall
Posted: Thu Oct 25, 2018 8:46 pm
by KhrougH
Re: clicking on a wall
Posted: Fri Oct 26, 2018 12:22 am
by Isaac
Re: clicking on a wall
Posted: Sun Oct 28, 2018 6:14 pm
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