LOG 2 Scripting 2

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!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

LOG 2 Scripting 2

Post by Mysterious »

Ok sorry to be a pain in the butt , but scripts are not working like they use to. So I think ill have to wait for Assets or Script definitions here. I have tried lots of basic Scripts from the original LOG 1 and the script definitions have changed. Eg:

1 - This is a script that opens a door when 2 torches are put into 2 torch holders. It wont run and comes up with the error
(attempt to call method 'hasTorch' (a nil value)

Code: Select all

function DoorOpen1()

if torch_holder_12:hasTorch() == true and
torch_holder_13:hasTorch() == true then
dungeon_door_wooden_4:open()
	else
dungeon_door_wooden_4:close()
end
	end
2 - This script when 2 locks are connected to it should open a door. (prison_lock) is the counter value = 0. When I put a Key into the lock it has the error (attempt to perform arithmetic on global 'prison_lock' (a table value)

Code: Select all

function PrisonLocks()

playSound("secret")
prison_lock = prison_lock + 1

if prison_lock==1 then
hudPrint("First lock unlocked.")
elseif prison_lock==2 then
hudPrint("Second lock unlocked.")

findEntity("dungeon_door_wooden_2"):open()

hudPrint("Prison Mines are now accessable")
hudPrint("")
end
	end
3 - Ok this I used this a lot in LOG 1 but does not work either. Basicaly the alcove or altar connects to the Script and does it's thing.
The error it comes up with is (attempt to call method 'getItemCount' (a nil value)

Code: Select all

function checkDoor1(self)

local alcove = findEntity("altar_1")
if (alcove ~= nil)and(alcove:getItemCount()>0) then
local item for item in alcove:containedItems() do
if item.name == "rock" then

--- Destroy Items here ---
self:destroy() -- This will Destroy the LOCK REM THIS --
item:destroy() -- Destroy the Key --

-- HudPrints Here and Key lock Sound and Fx's --
hudPrint("Yes the Yuanti Dagger is mine.")
party:shakeCamera(1,1)

dungeon_door_wooden_1:open()
	else
hudPrint("")
end
	end
		end
			end
So as I have found out a lot of functions for objects just don't cut it in LOG2, all the basic scripting the community has put out there more or less wont work. I have tried many, many scripts and face the same problems eg nil value, methods etc.... So I am going to take a wild guess here scripting will have to be learned all over again I think not sure I could be wrong, I am not the best at scripting but I try. Maybe the scripts have to be varied. I will have to wait anyway that's it :)

Oh and by the way Thank you to Almost Human for a awesome new Editor, good job guys I love it very much, thxs to Skuggs for the videos. I have learnt heaps from them :)
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: LOG 2 Scripting 2

Post by Komag »

Well, it's still Lua, just new definitions and stuff, no problem. All the old scripts can simply be "translated", so all the old hard work will not be wasted at all :)
Finished Dungeons - complete mods to play
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: LOG 2 Scripting 2

Post by Mysterious »

Thxs for the reply Komag I have studied all the scripts you did in the rework of LOG1 and it made my life easier and with others.
So yes I have to agree with you it can only get better from here on thxs again. You did a awesome job with the rework :)
A100N
Posts: 15
Joined: Sun Oct 19, 2014 1:53 pm

Re: LOG 2 Scripting 2

Post by A100N »

Hello all (sorry I use a translator)

Looking for help on the merits the scripts
namely,

*** I have 3 altars, and I want that when placed on each of them corresponding object automatically been opened one of the doors, ***

Unfortunately, a lot of scripts game changed in August compared with the earlier ver of this game and already can not keep anything that would Find an helped me

So if someone would be so kind and wrote me these few lines of code how it should look ??
Thanks in advance for your help ...
Post Reply