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!
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 »

What i'm looking for is to get that "+" sign, that lets you add connectors (inside the editor) to a component, to work on a ControllerComponent.
Same as you have on for example a LeverComponent.

For now i am using a LeverComponent instead of a ControllerComponent. but then i need to add an dummy animation, that returns false. Also i get warnings when i don't have an model.

This is just something minor but wanted to ask in case I missed something.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Hei&Yin wrote:What i'm looking for is to get that "+" sign, that lets you add connectors (inside the editor) to a component, to work on a ControllerComponent.
Same as you have on for example a LeverComponent.

For now i am using a LeverComponent instead of a ControllerComponent. but then i need to add an dummy animation, that returns false. Also i get warnings when i don't have an model.

This is just something minor but wanted to ask in case I missed something.
This functionality doesn't exist. ControllerComponent doesn't have any connector events. However, instead of using LeverComponent for your hack, you should just use CounterComponent.
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
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is it possible to test the existence of a file or list the content of a directory ? Still learning Lua, I just found that the standard io library is unknown in grimrock scripting ?
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

No. If it were, it would be an enormous security hole.
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
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Security holes are fun !!! I was trying to access the portraits directory to populate taverns with generated recruitable champions.
sajon
Posts: 38
Joined: Fri Nov 08, 2013 7:17 am

Re: Ask a simple question, get a simple answer

Post by sajon »

Ok i am trying to call a function inside a script_entity form another script_entity but cannot get it to work...

Example:
script_entity_1

Code: Select all

function startSequence()
   print("Sequence started...")
	delayedCall(self.go.id, 1, "sfireball")
   delayedCall(self.go.id, 1.5, "firstEvent")
   delayedCall(self.go.id, 10, "secondEvent")
end

function firstEvent()
   print("This script is run 1.5 seconds after the start.")
end

function secondEvent()
   print("This is printed 10 seconds after start.")
end

function sfireball()
   script_entity_2.fireaway() -- This is where i get an error
end
script_entity_2

Code: Select all

function fireAway()
spawn("fireball_small",1,14,15,1,0)
end
I get error attempt to call field 'fireAway' (a nil value)

What am i doing wrong??
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

script_entity_2.script.fireAway() not script_entity_2.fireaway()
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.
sajon
Posts: 38
Joined: Fri Nov 08, 2013 7:17 am

Re: Ask a simple question, get a simple answer

Post by sajon »

minmay wrote:script_entity_2.script.fireAway() not script_entity_2.fireaway()
so i forgot to tell it that it was a script xxxx.script.xxxx()
thanks
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

sajon wrote:
minmay wrote:script_entity_2.script.fireAway() not script_entity_2.fireaway()
so i forgot to tell it that it was a script xxxx.script.xxxx()
thanks
This is because the *.script is a script component in the object.
sajon
Posts: 38
Joined: Fri Nov 08, 2013 7:17 am

Re: Ask a simple question, get a simple answer

Post by sajon »

So my scripting is not that good....
i am trying to reset a series of pressure plates

allPlates is the ID's of my pressure plates.
I want to just enable all those plates by a trigger, but i also want to figure out how to use an array to store variables to use in loops.
Here is the code i am trying to get to work but it won't.

Code: Select all

function Plates()
  local allPlates = {"T1_Plate1", "T1_Plate2", "T1_Plate3", "T1_Plate4", "T1_Plate5", "T1_Plate6", "T1_Plate7", "T1_Plate8", "T1_Plate9", "T1_Plate10"}
	--print (allPlates)  
for i=1,10 do allPlates[i].floortrigger:enable(true)
end
end
Thanks for the help...
Post Reply