Hi everyone,
i'm trying to debug some script i did, that doesn't work properly, and i found that i cannot access variable from console.
Beeing specific:
access to external file form a script entity
generate some global variables, not in a function
then use those variables in some functions
some function works fine some other don't
so i tryed to acces variable from console and i always get nil, even for those variables that are obviously working
anyone knows why this thing happens?
thank you
Accessing varibles from console [SOLVED]
Accessing varibles from console [SOLVED]
Last edited by Granamir on Wed Feb 04, 2015 5:08 pm, edited 1 time in total.
Re: Accessing varibles from console
You cannot modify the global environment in Grimrock. Variables declared in a ScriptComponent outside of any block are not global, they are just permanent fields of that ScriptComponent. So if you have the following in a ScriptComponent:
then running the following code in the console will print nil twice:
Instead you need to reference them like this:
Code: Select all
stuff = "cows"
function doSomething()
print(stuff)
end
Code: Select all
print(stuff)
print(doSomething)
Code: Select all
print(script_entity_1.script.stuff)
print(script_entity_1.script.doSomething)
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: Accessing varibles from console
Understood
Thank you very much
Thank you very much