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!
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Do we know how many icons and spellIcons exist in the default atlases ? It seems to accept high int numbers, too high to test them all... Is there a cyclic reference past the max icon ID ?
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Ok I checked it, there are 25 spellIcons (0 to 24) and 120 icons (0 to 119) in the default atlas if it can help anyone !
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Ask a simple question, get a simple answer

Post by cameronC »

is there a correct way for loadFile in a Script component to be called correctly in a definition? Basically I have a script entity with multiple, specifically named Script components that I want to load from an external file without selecting the files in the editor. It's really not too big of a deal, just curious... Or is there a better way to do this?
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Is the method of damage calculation known for melee weapons? The range varies quite a bit depending on strength, skill, and the weapon used.

I'd like to be able to approximate the likely attack damage by a given champion with a given weapon ~by inspecting the skills, weapon, and stats.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Isaac wrote:Is the method of damage calculation known for melee weapons? The range varies quite a bit depending on strength, skill, and the weapon used.

I'd like to be able to approximate the likely attack damage by a given champion with a given weapon ~by inspecting the skills, weapon, and stats.
The average damage for an attack with X attack power is X, according to calcDamage().
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.
grimMod
Posts: 4
Joined: Mon Jan 12, 2015 10:07 am

Re: Ask a simple question, get a simple answer

Post by grimMod »

Hi,
creating my first mod and noticed something.
If calling a scriptfunction with parameter directly from another script (or console) it sends an extra parameter. delayedCall does not.

Calling from another script with scriptobject.script:functionname(param1, param2): The function will receive a table as first param, not param1. param2 will be received as original param1. The table seems to be the receivers script component.
Calling from console with scriptobject.script:functionname(param1, param2) seems to behave the same as above.
Calling with delayedcall("scriptobject",0,"functionname","param1","param2") works and the function receives the correct parameters.

Is this intended or a bug?

To recreate:
Create two script entities in map, script_entity_1 and script_entity_2.

script_entity_1 code:
SpoilerShow
function doSomething(param1, param2)
print("type(param1): "..type(param1).." type(param2): "..type(param2))
if type(param1) == "table" then print("param1(table): "..param1.go.id) end
if type(param1) == "string" then print("param1(string): "..param1) end
if type(param2) == "string" then print("param2(string): "..param2) end
end
script_entity_2 code:
SpoilerShow
print(">>>>")
function startit()
delayedCall("script_entity_1", 2, "doSomething", "delayedcallp1", "delayedcallp2")
script_entity_1.script:doSomething("directp1", "directp2")
end
Then put a floor trigger with connector to script_entity_2:startit and step on the floor trigger. Watch the result in the console.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

grimMod wrote:Hi,
creating my first mod and noticed something.
If calling a scriptfunction with parameter directly from another script (or console) it sends an extra parameter. delayedCall does not.

Calling from another script with scriptobject.script:functionname(param1, param2): The function will receive a table as first param, not param1. param2 will be received as original param1. The table seems to be the receivers script component.
Calling from console with scriptobject.script:functionname(param1, param2) seems to behave the same as above.
Calling with delayedcall("scriptobject",0,"functionname","param1","param2") works and the function receives the correct parameters.

Is this intended or a bug?
Lua 5.2 Reference Manual
You might find this useful to read as well: http://en.wikipedia.org/wiki/Object-ori ... rogramming

"scriptobject" is a table with a field named "script".
"script", in turn, is a table with a field named "functionname".
If you call it with "script.functionname()", the function is called "unbound", i.e. "normally".
If you call it with "script:functionname()", the function is called "bound", i.e. script will be passed as the first parameter. This is Lua's equivalent to methods. It's the same as calling "script.functionname(script)".
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.
grimMod
Posts: 4
Joined: Mon Jan 12, 2015 10:07 am

Re: Ask a simple question, get a simple answer

Post by grimMod »

minmay wrote:
grimMod wrote:Hi,
creating my first mod and noticed something.
If calling a scriptfunction with parameter directly from another script (or console) it sends an extra parameter. delayedCall does not.

Calling from another script with scriptobject.script:functionname(param1, param2): The function will receive a table as first param, not param1. param2 will be received as original param1. The table seems to be the receivers script component.
Calling from console with scriptobject.script:functionname(param1, param2) seems to behave the same as above.
Calling with delayedcall("scriptobject",0,"functionname","param1","param2") works and the function receives the correct parameters.

Is this intended or a bug?
Lua 5.2 Reference Manual
You might find this useful to read as well: http://en.wikipedia.org/wiki/Object-ori ... rogramming

"scriptobject" is a table with a field named "script".
"script", in turn, is a table with a field named "functionname".
If you call it with "script.functionname()", the function is called "unbound", i.e. "normally".
If you call it with "script:functionname()", the function is called "bound", i.e. script will be passed as the first parameter. This is Lua's equivalent to methods. It's the same as calling "script.functionname(script)".
Thanks for clearing up my confusion :)
User avatar
Vandalar
Posts: 31
Joined: Sun Jan 18, 2015 6:05 pm
Location: Montreal, Canada

Re: Ask a simple question, get a simple answer

Post by Vandalar »

Hello everyone,

Here's my first question :
Is there a way to close the player/champion inventory if it is open ?

Context : I defined a onClick event for a npc/statue, but if the player fiddle/manipulate things in the inventory while the dialog of the npc is in progress, it send another "onClick", which force the npc to go through the next set of dialog/speech. I could remove the onClick connector/hook while the speech is in progress, but I would rather know how to close the inventory (and for my own education !)

I assume it's related to the party object, so I checked the Scripting Reference, but I couldn't find anything for closing inventory. The closest thing I found was :

Code: Select all

PartyComponent.onDrawInventory(self, context, champion)
but I don't know how I can use it, if I can use it at all.

Thanks in advance,
PS : Sorry for any spelling/grammar error. English second language here.
quailman84
Posts: 1
Joined: Thu Jan 22, 2015 8:21 pm

Re: Ask a simple question, get a simple answer

Post by quailman84 »

How does one reference a variable found in a script from the console or from a different script entity? I found a Grimrock 1 thread saying that you just do (scripting entity id).(variable name), but I can't get that to work. Is the process different in Grimrock 2, or am I just being dense?

For clarity's sake, this is what I am doing: I create a script entity with the id "se". The script embedded in that entity consists solely of the line "foo = 1". No functions or anything, just that line. Then, if I create a script that prints se.foo, it prints nil. Same for if I reference or print se.foo from the console.

Thanks in advance for any help offered.

Edit: Figures I solve the problem on my own just minutes after wrestling with it for an hour and registering here just so I could ask. By accessing se, I was only accessing the game object, not the script contained within the game object. To access the script, you need to do se.script, and therefore se.script.foo to access the variable found inside the script.
Post Reply