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!
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Ask a simple question, get a simple answer

Post by NutJob »

Is there a way to print to a text/log file instead of the screen? I understand, that if there was, it would be a problem with compiled modules (exported) and modders potentially could write something malicious but looking for something that would only work in a development setting (the editor).
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: Ask a simple question, get a simple answer

Post by QuintinStone »

NutJob wrote:Is there a way to print to a text/log file instead of the screen? I understand, that if there was, it would be a problem with compiled modules (exported) and modders potentially could write something malicious but looking for something that would only work in a development setting (the editor).
JohnWordsworth's script to get object definitions does something pretty brilliant.
viewtopic.php?f=22&t=8439

It dumps the text into a script object definition so that while running the dungeon in preview mode, you can place that script object into your map. When you view the source of the object, all the text appears and it can be copy-pasted to any text editor outside the game.
Crypt of Zulfar
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

What do I use to define a large group of assets instead of this which doesn't seem to work for grimrock 2.

for i in allEntities(party.level) do
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

for i in party.map:allEntities() do
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.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

Don't know what I'm doing wrong, or why the scripting ref changed so much.

function massopenpit()
for i in party.map:allEntities() do
if i.id:sub(1,8) == "tomb_pit" then
if i:isOpen() then
i:close()
else
i:open()
end
end
end
end

PitComponent:isOpen() also doesn't work
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

function massopenpit()
for i in party.map:allEntities() do
if i.id:sub(1,8) == "tomb_pit" then
if i.pit:isOpen() then
i.pit:close()
else
i.pit:open()
end
end
end
end

Always take off the "Component" when looking at the scripting reference
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Soaponarope wrote:Don't know what I'm doing wrong
You're trying to call methods that don't exist.
Soaponarope wrote:or why the scripting ref changed so much.
Because it's Grimrock 2 and not Grimrock 1.
Soaponarope wrote:function massopenpit()
for i in party.map:allEntities() do
if i.id:sub(1,8) == "tomb_pit" then
if i:isOpen() then
i:close()
else
i:open()
end
end
end
end

PitComponent:isOpen() also doesn't work
Because GameObject doesn't have an isOpen() method, GameObject doesn't have a close() method, GameObject doesn't have an open() method, and "PitComponent" is the name of the class, not an actual instance of it. You probably wanted to call i.pit:isOpen(), i.pit:close(), etc. All of this information is in the scripting reference.
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.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Ask a simple question, get a simple answer

Post by Soaponarope »

Thank you both, working now.

I am using the scripting reference, but I don't know scripting and I'm sometimes not sure what I'm looking for.(like taking off the "component")
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Ask a simple question, get a simple answer

Post by cameronC »

I just can't get delayedCall to work. I've combed through the various posts regarding it in other threads and the brief mention of it in the scripting ref but I think I'm completely misunderstanding it. I've tried many things to get a script function to be ran after X seconds and sometimes the editor crashes on delayedCall() and sometimes it passes through it fine but gives me an invalidconnector warning onscreen and nothing else happens.

If I have entityID with a functionName I want to run after X seconds, is that something this can do?
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
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: Ask a simple question, get a simple answer

Post by QuintinStone »

cameronC wrote:I just can't get delayedCall to work. I've combed through the various posts regarding it in other threads and the brief mention of it in the scripting ref but I think I'm completely misunderstanding it. I've tried many things to get a script function to be ran after X seconds and sometimes the editor crashes on delayedCall() and sometimes it passes through it fine but gives me an invalidconnector warning onscreen and nothing else happens.

If I have entityID with a functionName I want to run after X seconds, is that something this can do?
I'm currently having problems too. I'm trying to call the stop() method on an object's controller component.

delayedCall(obj.go.id, 1, "stop") produces no results
delayedCall(obj.go.id, 1, "controller:stop") produces no results
Crypt of Zulfar
Post Reply