General scripting issues and questions

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

General scripting issues and questions

Post by JKos »

Hi and thanks for releasing the beta :)

I will start with a simple question.
Why doesn't this work? is it a bug or just me?

damageTile(1, dungeon_door_iron_1.x, dungeon_door_iron_1.y, 1, 1, "physical", 2)

it gives following error: attempt to index a nil value. But only if there is a monster on that tile.

full script:
function crushEast()
if (dungeon_door_iron_1:isOpen()) then
dungeon_door_iron_1:close()
damageTile(1, dungeon_door_iron_1.x, dungeon_door_iron_1.y, 1, 1, "physical", 2)
else
dungeon_door_iron_1:open()
end
end

Suggestion for scripting reference: Add simple example for every method/function, or at least to more complex ones like this, everyone loves examples :) for example I don't know what bit field means in lua (and google isin't helping much), is it just a integer from 0 - 256 or something like 00000001 or what? With an simple function-call example of it would have been very easy to me figure it out.

Thanks.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

Re: General scripting issues and questions

Post by antti »

Oh, this seems like a bug. The monster should receive damage just fine. Thanks for finding it out!

Bit field is something that we should probably cover in the guides somewhere. It's basically 8 bits converted into an integer. You can think of each of the bits as a true/false boolean. For example, if you would like to cause damage that the monster recoils from (bit 0) and which ignores immunities (bit 6). The resulting binary number would be 10000010 which, when you converted to an integer, totals 128+2 = 130, the number you would need to enter into the script in this example case.
Steven Seagal of gaming industry
lowzei
Posts: 99
Joined: Tue Mar 27, 2012 12:00 pm

Re: General scripting issues and questions

Post by lowzei »

Yay, about another hour for playing around with the editor.

I still would like to know if it's possible not only to read but also to set the location and orientation of a party (or any other entity), like obj:setpos(x,y,z,r). Does this work and if, how? I can read out this information, i can spawn new entities but how about altering already existing ones like your party?

Would be happy if someone could point me into the proper direction, otherwise i'll have to alter the design of some riddles i intended to implement.

Thanks...
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: General scripting issues and questions

Post by petri »

You can use a teleporter entity to transport items/monsters/party.
lowzei
Posts: 99
Joined: Tue Mar 27, 2012 12:00 pm

Re: General scripting issues and questions

Post by lowzei »

But as teleporters only operate on a level i can't for instance let a party fall into a pit, pace a teleporter below and teleport them to the desired position one level above again. Or is this possible? If so, how?
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: General scripting issues and questions

Post by petri »

You can change the target level of a teleporter in the inspector.
lowzei
Posts: 99
Joined: Tue Mar 27, 2012 12:00 pm

Re: General scripting issues and questions

Post by lowzei »

Okay, thanks, i did a quick test, it doesn't work fully. The teleporter isn't activated when the party is falling down. You need to leave the teleporter and reenter the field in order to get teleported. Any idea how to get this running, so that you get teleported instantly once (or even before) you hit the ground?
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: General scripting issues and questions

Post by JKos »

antti wrote:Oh, this seems like a bug. The monster should receive damage just fine. Thanks for finding it out!
I tested it bit more and this bug occurs only when damage type is "physical".
Also there is a small error in function description: damageType must be on of the following: “physical”, “fire”, “poison”, “cold”, “poison”. I believe that the 5th should be "shock".
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: General scripting issues and questions

Post by Montis »

I'm currently a bit puzzled... I'm new to lua but have a bit of scripting experience, so this seems strange to me:
The following code doesn't work properly, it outputs an error in the hudPrint line (string expected). Only when I remove the "local" from the pronoun variable it will work. Is this intended, since I don't really want that variable to have a global scope.

Code: Select all

	if party:getChampion(1):getSex() == "male" then
		local pronoun = "he"
		else
		local pronoun = "she"
	end
	hudPrint(pronoun)
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Filipsan
Posts: 84
Joined: Fri Mar 16, 2012 10:18 am

Re: General scripting issues and questions

Post by Filipsan »

Code: Select all

local pronoun = ""
if party:getChampion(1):getSex() == "male" then
      pronoun = "he"
else
      pronoun = "she"
end
hudPrint(pronoun)
Post Reply