Ask a simple question, get a simple answer
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
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 ?
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
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 !
Re: Ask a simple question, get a simple answer
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
Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
Re: Ask a simple question, get a simple answer
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.
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.
Re: Ask a simple question, get a simple answer
The average damage for an attack with X attack power is X, according to calcDamage().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.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
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:
script_entity_2 code:
Then put a floor trigger with connector to script_entity_2:startit and step on the floor trigger. Watch the result in the console.
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
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
SpoilerShow
print(">>>>")
function startit()
delayedCall("script_entity_1", 2, "doSomething", "delayedcallp1", "delayedcallp2")
script_entity_1.script:doSomething("directp1", "directp2")
end
function startit()
delayedCall("script_entity_1", 2, "doSomething", "delayedcallp1", "delayedcallp2")
script_entity_1.script:doSomething("directp1", "directp2")
end
Re: Ask a simple question, get a simple answer
Lua 5.2 Reference ManualgrimMod 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?
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Ask a simple question, get a simple answer
Thanks for clearing up my confusionminmay wrote:Lua 5.2 Reference ManualgrimMod 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?
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)".
Re: Ask a simple question, get a simple answer
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 :
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.
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)
Thanks in advance,
PS : Sorry for any spelling/grammar error. English second language here.
-
- Posts: 1
- Joined: Thu Jan 22, 2015 8:21 pm
Re: Ask a simple question, get a simple answer
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.
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.