Page 97 of 400
Re: Ask a simple question, get a simple answer
Posted: Fri Oct 09, 2015 2:23 am
by Isaac
AndakRainor wrote:Is there any way to deactivate the throwing of mouse item ? I made a small window where I would like to drag and drop items, but when I click on it the mouse item is thrown.
How did you make the window?
Here is a simple option that restricts throwing, but not dropping; and calls a function when clicked.
Code: Select all
useTrigger = true --auto-spawns a connected floor_trigger on the tile
windowActive = false
function click_action(bool)
if bool then
--_________________________ Change script to suit
local item = getMouseItem()
if item then
hudPrint("You clicked the window with a "..item.go.name..".")
end
--_________________________
end
end
_createWindow = function(context)
if not context.mouseDown(2) and party.facing == self.go.facing
and party.x == self.go.x and party.y == self.go.y
and party.elevation == self.go.elevation --can be commented out
then
local dir, result = context.button(self.go.id.."window", 0, 0, context.width, context.height * .6)
if result then
click_action(context.mouseDown(3))
end
end
end
function _setWindowActive(bool)
windowActive = bool
print(bool)
end
function activate()
windowActive = true
end
function deactivate()
windowActive = false
end
function toggleWindowActive()
windowActive = not windowActive
end
if useTrigger then
self.go:spawn('floor_trigger').floortrigger:addConnector('onToggle', self.go.id, "toggleWindowActive")
end
Code: Select all
defineObject{
name = "party",
components = {
{
class = "Party",
onMove = function(self, dir) end,
onDrawGui = function(self, context) window2.script.createWindow(context) end,
},
{
class = "Light",
name = "torch",
range = 12,
},
},
editorIcon = 32,
placement = "floor",
}
To use this, define onDrawGui (in a party definition, in objects.lua) to call the _createWindow function in the script_entity.
Then position and face the script _entity to indicate the tile and direction where the window is. Activate the effect
either via script using one of the setter functions, or via the built in trigger/plate (which is automatically spawned by default).
Re: Ask a simple question, get a simple answer
Posted: Fri Oct 09, 2015 7:06 pm
by AndakRainor
I use the onDrawInventory of the party to draw this panel. It is a panel I use to craft potions, similar to the mortar menu of grimrock 1, next to the inventory instead of over the hands of the champion.
I don't use context.button in my code but context.drawGuiItem2 and context.drawImage2. Is it this function that restricts throwing in your example ?
Re: Ask a simple question, get a simple answer
Posted: Fri Oct 09, 2015 7:23 pm
by Isaac
The script makes an invisible button that covers the upper half of the screen, and intercepts clicks that are on the button. The button covers the area where the engine detects left clicks to initiate throwing a weapon.
Also... I've found a far simpler (and better) way to do this.
Just define this object and place it.
Code: Select all
defineObject{
name = "click_region",
baseObject = "base_wall_decoration",
components = {
{
class = "Clickable",
offset = vec(0, 2.2, -1),
size = vec(3, 3, .5),
--debugDraw = true,
onClick = function(self)
local click_actions = findEntity("click_actions")
local item = getMouseItem()
if click_actions and click_actions.script[self.go.id] then
click_actions.script[self.go.id]()
elseif item then
hudPrint("You clicked the window with a "..item.go.name..".")
end
end
},
}
}
Change the onClick event to suit; or you can add a script_entity with the id 'click_actions', and with a function in it of the same name as your click_region object's id.
Example: place a "click_region_2" object, and add a script_entity named "click_actions"...
Code: Select all
--script name is click_actions
click_region_2 = function()
playSound("secret")
local item = getMouseItem()
if item then
hudPrint("You clicked the window with a "..item.go.name..".")
end
end
You can place as many click_region objects as you like, and when clicked, they will each check the click_actions script for their own function to execute.
Re: Ask a simple question, get a simple answer
Posted: Sat Oct 17, 2015 6:13 pm
by AndakRainor
Is there a way to get the gfxIndexArmorSet value of an item ? I don't see the function for it in the scripting reference.
Re: Ask a simple question, get a simple answer
Posted: Fri Oct 23, 2015 6:45 pm
by TZO2k12
I've been hunting forever for a simple keyboard command ,list, specifically how do you duplicate an asset?

Re: Ask a simple question, get a simple answer
Posted: Fri Oct 23, 2015 10:28 pm
by THOM
You mean the editor? Did you had a look at file/preferences? You can change the key-commands.
To duplicate an object just use ctrl-c and ctrl-v... The new object will lie over the old one, but it is selected and you can move it by using the arrow-keys...

Re: Ask a simple question, get a simple answer
Posted: Sat Oct 24, 2015 4:55 am
by FeMaiden
ignore me...i just had to comment on the irony. this thread is titled "....simple question...simple answer" and half of these scripts I see are like a whole nother league above my pay grade. I haven't even begun to understand the complexity...
I haven't gotten past bossfights hudPrints and the intro to "if then else".
but the double irony is that these probably really ARE simple, to the people that wrote them.
Re: Ask a simple question, get a simple answer
Posted: Sat Oct 24, 2015 5:01 am
by minmay
Well, what would you prefer? People answering the questions, or people saying "no, that question isn't simple enough for this thread, go away"?
Re: Ask a simple question, get a simple answer
Posted: Sat Oct 24, 2015 5:52 am
by Azel
FeMaiden wrote:ignore me...i just had to comment on the irony. this thread is titled "....simple question...simple answer" and half of these scripts I see are like a whole nother league above my pay grade. I haven't even begun to understand the complexity...
I haven't gotten past bossfights hudPrints and the intro to "if then else".
but the double irony is that these probably really ARE simple, to the people that wrote them.
I suppose then that we could say that "simple" is all a matter of perspective.
On one extreme, you have people who don't know much of anything about programming nor the Asset Pack and prefer to ask before trial n error; on the other end you have people (eg, minmay) who insist that you must memorize everything about LUA and Grimrock assets before you're allowed to speak; and somewhere in the middle are those of us who fumble through the pain of learning just enough to make something that someone hopefully finds worthwhile to play for longer than an hour.
Perhaps a better name for this thread is, "simply ask a question, and get either an answer from the community or a sarcastic response from minmay."
That's the dominant theme of the near 1,000 posts in this thread. All-in-all though, it's a fun read and a worthy cause (I think)

Re: Ask a simple question, get a simple answer
Posted: Sat Oct 24, 2015 6:32 am
by Dr.Disaster
FeMaiden wrote:ignore me...i just had to comment on the irony. this thread is titled "....simple question...simple answer" and half of these scripts I see are like a whole nother league above my pay grade. I haven't even begun to understand the complexity...
I haven't gotten past bossfights hudPrints and the intro to "if then else".
but the double irony is that these probably really ARE simple, to the people that wrote them.
Yeah the title might irritate somebody new to modding. Think of it as "if then else" thread: straight question going for a straight answer(s) without fooling around.