Some Scripting Questions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
welchdrew
Posts: 15
Joined: Thu Sep 27, 2012 3:20 am
Location: Home of the Yoopers, Michigan's Upper Peninsula

Re: Some Scripting Questions

Post by welchdrew »

Shroom wrote:the cube also appears to ignore blockers (or it did, I haven't tried again in 11)

Edit:- Still ignores blockers in 1.2.11 too - Not that big a deal though.
It doesnt ignore Portals. Tested it with portals, and portals work just fine.
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: Some Scripting Questions

Post by Filipsan »

I would like to create an Replicator:

2 alcoves, 1 lever and one lua entity
when the lever is pulled, i can check items in alcoves
when both alcoves contain just one item, and one of them is for example rock (or anything else), a want to replace this rock with the item in the other alcove.

My 2(3) questions:

- is there a way to remove item (or just teleport it from the alcove somewhere else)
- is there a waz to clone item (or spawn a copy or whatever you can name it)? - found it on the forum :)

Code: Select all

replicator_alcove_1:addItem(spawn(original_item.name))
- if so, where can i find info about such functions?

Thanks!


EDIT:

Looks like i found a workaround, here is code for my replicator:

Code: Select all


replicator_used = false -- can use only once

function replicate()
	if(replicator_used==false) then
		checkAlcoveForItems()
	end
end

function checkAlcoveForItems()

	local itemCount1 = replicator_alcove_1:getItemCount()
	local itemCount2 = replicator_alcove_2:getItemCount()

	if( (itemCount1==1) and (itemCount2==1)) then
		 for i in replicator_alcove_1:containedItems() do
			if i.name == "replicator_token" then -- it's just a clone of rock with different name :)
				itemFound()
			end
		end
	end
end

-- run this script _once for each item_ with a matching name
function itemFound()
        --play sound, write text
	for a in replicator_alcove_2:containedItems() do
		replicator_alcove_2:addItem(spawn(a.name))  --replicate item in alcove_2
		replicator_used = true --cannot use it again
		dungeon_wall_text_1:setWallText("Not enough energy!") --change replicator description
		dungeon_secret_door_1:close() --close secret door before alcove eith token - player cannot pick it up again
	end
end
One qestion thou - can i modify function itemFound() so it does not use a for loop?
User avatar
Halluinoid
Posts: 165
Joined: Tue Apr 02, 2013 7:08 pm
Contact:

Re: Some Scripting Questions

Post by Halluinoid »

Cube still ignores blocker in latest release (that I just bought) :oops:

In addition, a white text error message on screen says: "Warning ! Responder not found with id: cube"
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Some Scripting Questions

Post by Komag »

that's a harmless error message
Finished Dungeons - complete mods to play
Post Reply