Defining object ingame
Defining object ingame
Ciao, have someone tried find the way how to define object in game? (in editor script)
Re: Defining object ingame
You can't define new objects while in editor but you can modify existing (spawned) objects considerably by modifying its components or creating new components. This can be suitable for some one-off objects but in general you're better off if you just do them the traditional way with the init scripts.
Steven Seagal of gaming industry
Re: Defining object ingame
On a side-note: defining custom stuff in-game and reverse-engineering definitions:
is there a way to let's say dump item definition (every component and it's parameters) into array (like item is defined with defineObject) so it can be further printed with
I've tried that with console:
sb = spawn("short_bow")
script_entity_1.script.tprint(sb) but nothing happens.
Maybe i should try doing it with GameObject:getComponent(name) to save every component into array ?
:EDIT: I think something is wrong with my tprint function, because:

value sb clearly is a table.
is there a way to let's say dump item definition (every component and it's parameters) into array (like item is defined with defineObject) so it can be further printed with
Code: Select all
function tprint (tbl, indent)
if not indent then indent = 0
end
for k, v in pairs(tbl) do
formatting = string.rep(" ", indent) .. k .. ": "
if type(v) == "table" then
print(formatting)
tprint(v, indent+1)
else
print(formatting .. v)
end
end
end
sb = spawn("short_bow")
script_entity_1.script.tprint(sb) but nothing happens.
Maybe i should try doing it with GameObject:getComponent(name) to save every component into array ?
:EDIT: I think something is wrong with my tprint function, because:

value sb clearly is a table.
Re: Defining object ingame
I have noticed this too. pairs() and ipairs() doesn't return anything on Grimrock objects. They work fine on tables you make yourself. I am sure this was done on purpose for whatever reason (probably doing a metamethod command on the tables so they cannot be iterated).
We can only go off of the documentation and trial and error to figure these out.
We can only go off of the documentation and trial and error to figure these out.