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
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber » Mon Mar 09, 2015 9:56 am

So it needs to be stereo?
My asset pack [v1.10]
Features a bit of everything! :D

minmay
Posts: 2700
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Mon Mar 09, 2015 10:17 am

Sounds NEVER need to be stereo. But 3D sounds CANNOT be stereo. 2D sounds can be stereo or mono.
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
THOM
Posts: 1181
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Tue Mar 10, 2015 12:34 am

is there a way to ask if a socket holds NOT a specific item?

I have 4 sockets. several doors have to open if the combination of gems in them is right.

so what works well is

Code: Select all

function socketContains(socket, item)
   for _,i in socket:contents() do
      	if i.go.name == item then return true
	end
   end
end

function checkSockets()
	if 	socketContains(gem_socket_A.socket, "green_gem") and
		   socketContains(gem_socket_B.socket, "green_gem")
		then
		waterwall_6.controller:deactivate()
		else
		waterwall_6.controller:activate()
	end
end
But now I have to check if socketA has a gem, socketB has a gem, socketC has everything but not a gem, socketD has everything but not a gem.

Is there a way to deny the query?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

User avatar
THOM
Posts: 1181
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Wed Mar 11, 2015 12:29 am

concerning to my previous post: it seems there is nothing like an "if not" command, right? :|
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

Zo Kath Ra
Posts: 866
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra » Wed Mar 11, 2015 12:34 am

THOM wrote:concerning to my previous post: it seems there is nothing like an "if not" command, right? :|
http://lmgtfy.com/?q=lua+if+not ;)

User avatar
Isaac
Posts: 3005
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Wed Mar 11, 2015 12:50 am

THOM wrote:concerning to my previous post: it seems there is nothing like an "if not" command, right? :|
http://stackoverflow.com/questions/1165 ... hat-in-lua
http://www.troubleshooters.com/codecorn/lua/luaif.htm

User avatar
THOM
Posts: 1181
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM » Wed Mar 11, 2015 1:37 am

found out, this works

Code: Select all

if socketContains(gem_socket_A.socket, "green_gem") then
   if not socketContains(gem_socket_B.socket, "green_gem") and
   not socketContains(gem_socket_C.socket, "green_gem") and
   not socketContains(gem_socket_D.socket, "green_gem") 
then
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download

Hei&Yin
Posts: 2
Joined: Sun Oct 19, 2014 3:54 pm

Re: Ask a simple question, get a simple answer

Post by Hei&Yin » Wed Mar 11, 2015 9:49 pm

Is it possible to make a ControllerComponent where you can add connectors, without scripting, inside the editor?

Have tried to use Component:addConnector(event, target, action) in a few ways without results.
Done a workaround using a LeverComponent for now.

minmay
Posts: 2700
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay » Wed Mar 11, 2015 10:13 pm

Hei&Yin wrote:Is it possible to make a ControllerComponent where you can add connectors, without scripting, inside the editor?

Have tried to use Component:addConnector(event, target, action) in a few ways without results.
Done a workaround using a LeverComponent for now.
I have no idea what you are actually asking here. When you add a connector to a component, that component needs to have a corresponding event to trigger the connector. For example, LeverComponent has an onActivate event. When it calls its onActivate hook, it will also call any onActivate connectors that it has.
When a connector is triggered, it tries to find the target entity, and if successful, calls the action function in the component of that entity named "controller". For example, door objects have a ControllerComponent named "controller" with onOpen, onClose, and onToggle hooks, so the action can be "open", "close", or "toggle". script_entity objects have a ScriptControllerComponent named "controller" which can see all public functions defined in the object's ScriptComponent named "script", so if you define a function called "moo" in that ScriptComponent, a connector with that object as its target can use "moo" as an action.
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
Isaac
Posts: 3005
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac » Wed Mar 11, 2015 10:18 pm

minmay wrote:
Hei&Yin wrote:Is it possible to make a ControllerComponent where you can add connectors, without scripting, inside the editor?

Have tried to use Component:addConnector(event, target, action) in a few ways without results.
Done a workaround using a LeverComponent for now.
I have no idea what you are actually asking here.
Sounds like Hei&Yin is looking for a node editor after a fashion... similar to Kismet/trueSpace/Blender logic & node material editors.
Visual scripting via the GUI.

@Hei&Yin: That doesn't exist in the editor; except as seen in the connector UI for triggers and teleporters. It could be a neat feature to add, but probably more work than it's worth. It's far easier to spend a day learning the basics of the task using script; unless you have a specific reason that demands a scriptless GUI?

Post Reply