Script problem

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
nidone
Posts: 4
Joined: Sat Sep 15, 2012 6:39 am

Script problem

Post by nidone »

I'm totally sucks at scripting, and this question probably would be a most stupid question ever!
Anyway,i've got a problem. Look at the preview window:
SpoilerShow
Image
100% i'm doing something wrong, but what?

P.S. And sorry for my terrible english :)
LucidPanic
Posts: 1
Joined: Sat Sep 15, 2012 9:04 am

Re: Script problem

Post by LucidPanic »

I think you want to test the little Hello World script from http://www.grimrock.net/modding/introdu ... scripting/ , right ?

Code: Select all

-- hello world script
function hello()
	print("Hello world!")
end
I think i can explain that code snippet:
-- hello world script
this first line is a comment, which is useful for describe / document code, which itself is ignored by the engine, it starts with double "-"
function hello()
the second line defines a function named hello - which will appear in the connector action field, you can name it differently if you want: SayHello_1, Say_Hello_2 etc
print("Hello world!")
print should paste the worlds in the quota in the bracket into the console - they will NOT appear to the player. If you want to show some text to the PLAYER use hudPrint
end
It shows where the end of the function is, so you can define multiple functions in one script and use them in different situations:

Code: Select all

-- some Hello Messages

function sayHello_1()
  hudPrint("Hello world!")
end

function sayHello_2()
  hudPrint("Hello again!")
end

I have only faint idea how to trigger those funtions - i believe you can put some lever, pressure plate - and connect it to the LUA script on activation, and define the action / function there.

HTH
ps. sorry for the english too;)
User avatar
nidone
Posts: 4
Joined: Sat Sep 15, 2012 6:39 am

Re: Script problem

Post by nidone »

LucidPanic wrote:I think you want to test the little Hello World script from http://www.grimrock.net/modding/introdu ... scripting/ , right ?

Code: Select all

-- hello world script
function hello()
	print("Hello world!")
end
I think i can explain that code snippet:
-- hello world script
this first line is a comment, which is useful for describe / document code, which itself is ignored by the engine, it starts with double "-"
function hello()
the second line defines a function named hello - which will appear in the connector action field, you can name it differently if you want: SayHello_1, Say_Hello_2 etc
print("Hello world!")
print should paste the worlds in the quota in the bracket into the console - they will NOT appear to the player. If you want to show some text to the PLAYER use hudPrint
end
It shows where the end of the function is, so you can define multiple functions in one script and use them in different situations:

Code: Select all

-- some Hello Messages

function sayHello_1()
  hudPrint("Hello world!")
end

function sayHello_2()
  hudPrint("Hello again!")
end

I have only faint idea how to trigger those funtions - i believe you can put some lever, pressure plate - and connect it to the LUA script on activation, and define the action / function there.

HTH
ps. sorry for the english too;)
Got it! Thanks. But i still can't put down the strings! Shift+Enter, Ctrl+Enter and whatever+Enter doesn't works. Also i can't paste code in console.

Before that i was doing custom assets (items.lua), and did it successfuly
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: Script problem

Post by Shroom »

For a line return use \n

Use hudPrint to show it in game rather than print

To trigger code:-
Add a pressure_plate_hidden
Select the plate
Add a connector - connect it to your lua script entity - in the action make sure sayhello_1 is selected
Set the other plate options

If you want to toggle to a second plate, you can add two and deactivate the first and activate the second after the first is 'run'
Or you can use a counter to run a different function (more script code)

Job done :)
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Script problem

Post by Montis »

Image

Place this somewhere on the map, then paste the code in there.
Afterwards connect a trigger (like a lever, pressure plate) to the script entity and choose the function to trigger.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
nidone
Posts: 4
Joined: Sat Sep 15, 2012 6:39 am

Re: Script problem

Post by nidone »

Afterwards connect a trigger (like a lever, pressure plate) to the script entity and choose the function to trigger.
To trigger code:-
Add a pressure_plate_hidden
Select the plate
Add a connector - connect it to your lua script entity
Done.
Place this somewhere on the map, then paste the code in there
In there... in there... In what? I can paste in scrolls, notes, walltexts, but not in to the console :(
User avatar
nidone
Posts: 4
Joined: Sat Sep 15, 2012 6:39 am

Re: Script problem

Post by nidone »

OH WAIT! I just realised that this window is usable! :lol:
Image
I think it's just a free space! Damn. I need to sleep...

Thank all of you! And sorry for the inconvenience :D
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Script problem

Post by Komag »

NINJA WINDOW! nice 8-)
Finished Dungeons - complete mods to play
Post Reply