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!
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: Ask a simple question, get a simple answer

Post by kelly1111 »

Thanks that helped !
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

I'm trying to find a solution through counters for a button that rotates, sequentially, different force fields. And of course, it's not working. How could I solve this with a script??

The point is that when I'm using the "if" "then" + "else" method, I have only 2 outputs, and I need 4 different stages when pushing this button.
So> There are 4 force fields: the first click on the button will disable the first one. The second click will enable that first one, disabling only the second one. With the 3rd click, the 3rd is disabled. etc.
Any idea? Is there an alternative way to do that without using the "if+then+else"?

EDITED: I have to say that I actually solved WHAT I'm asking for through counters, but the real problem is that I need 2 buttons doing this with a total of 6 different force fields, 4 per button, 2 of which are shared in the buttons hahaha. So I think I need to do through scripting, as through counters there will be always 5 force fields activated (and I need to disable 2 of them).

Does it makes sense for you guys?

Thanks in advance guys! :)
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Sounds like a problem I want to help solve. I will post back in a little while with a prototype.

Say button A cycles forcefields 1-4, button B cycles forcefield 3-6. What do you want to have happen if both buttons are trying to disable the same forcefield? Off or on?

edit:

Code: Select all

acycle = 0
bcycle = 2

function buttonA()
	acycle = acycle + 1
	if acycle > 4 then
		acycle = 1
	end
	setTeleport()
end

function buttonB()
	bcycle = bcycle + 1
	if bcycle > 6 then
		bcycle = 3
	end
	setTeleport()
end

function setTeleport()
	for i = 1,6 do
		ff = findEntity("force_field_"..i)
		if i == acycle or i == bcycle then
			ff.controller:deactivate()
		else
			ff.controller:activate()
		end
	end
end
name your teleports "force_field_n" where n is a number from 1 through 6
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

GoldenShadowGS wrote:Sounds like a problem I want to help solve. I will post back in a little while with a prototype.

Say button A cycles forcefields 1-4, button B cycles forcefield 3-6. What do you want to have happen if both buttons are trying to disable the same forcefield? Off or on?

edit:

Code: Select all

acycle = 0
bcycle = 2

function buttonA()
	acycle = acycle + 1
	if acycle > 4 then
		acycle = 1
	end
	setTeleport()
end

function buttonB()
	bcycle = bcycle + 1
	if bcycle > 6 then
		bcycle = 3
	end
	setTeleport()
end

function setTeleport()
	for i = 1,6 do
		ff = findEntity("force_field_"..i)
		if i == acycle or i == bcycle then
			ff.controller:deactivate()
		else
			ff.controller:activate()
		end
	end
end
name your teleports "force_field_n" where n is a number from 1 through 6
Yeah, you understood correctly the request!

This is just.... awesome. Woah! I couldn't have discovered this combination in years... :shock: But it seems that is the answer to what I'm looking for.
I'm going to make some testing, and I'll post you back! Thanks A LOT!
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Here Is an improvement:

Code: Select all

acycle = 0
bcycle = 2

function buttonA(self)
	acycle = acycle + 1
	if acycle > 4 then
		acycle = 1
	end
	setTeleport(self.go.id)
end

function buttonB(self)
	bcycle = bcycle + 1
	if bcycle > 6 then
		bcycle = 3
	end
	setTeleport(self.go.id)
end

function setTeleport(button)
	for i = 1,6 do
		ff = findEntity("force_field_"..i)
		if button == "wall_button_1" then
			if i == acycle then
				ff.controller:deactivate()
			else
				ff.controller:activate()
			end
		elseif button == "wall_button_2" then
			if i == bcycle then
				ff.controller:deactivate()
			else
				ff.controller:activate()
			end
		end
	end
end
Now only one forcefield will deactivate at a time. This time the button names matter too. wall_button_1 and wall_button_2. if they are different, then change it in the script to match
User avatar
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

My personal Jesus, and I'm atheist!! :D
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Ask a simple question, get a simple answer

Post by cameronC »

CastSpellComponent (ItemActionComponent)

...

CastSpellComponent:setEmptyItem(string)
When using an item with this set in its definition the editor says it is an "invalid component property". The string I gave it was an item, assuming that once the charges of the spell were used up the item would become what i pass it in the string. Has anyone got this to work? Obviously emptyItem isn't the right name for this property...
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
Akimbo
Posts: 2
Joined: Fri Nov 21, 2014 3:48 pm

Re: Ask a simple question, get a simple answer

Post by Akimbo »

Missile Weapons are bad.

I want to make them better, starting with improving the skill.

Where do I even begin? Extract all the data for the game?

Thanks >_>
macBos
Posts: 35
Joined: Mon Jun 03, 2013 9:52 pm

Re: Ask a simple question, get a simple answer

Post by macBos »

Hi

I can't find option for disabling custom party creation for custom dungeon. I was wondering about replacing created party by predefined one (using script) but I was hoping for more elegant solution. If I just missed that somewhere, please let me know :)
User avatar
Ciccipicci
Posts: 154
Joined: Mon Oct 08, 2012 12:55 am

Re: Ask a simple question, get a simple answer

Post by Ciccipicci »

Hi. How to pop up a text line from one champion only when walking in a specific point or coordinates?
I'm using this

hudPrint(party.party:getChampion(x):getName() .. ": message you want the champion to say in quotes here" )

but the scripts pop up instantly everywhere.
Post Reply