[Solved]Assistance in creating a proper floor_trigger puzzle

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!
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Assistance in creating a proper floor_trigger puzzle

Post by Azel »

My post is irrelevant? Not at all. You've become quite full of yourself lately, minmay. It's cool that you have made LUA script your life, but you have some blind dedication and no real abilities beyond your memorization of a scripting reference. Here, I will show you how my approach can easily improve the brain fart you typed up:

Code: Select all

for counter=1,6 do
  local plate = findEntity("beach_pressure_plate_" .. counter);
  
  for e in plate.map:entitiesAt(plate.x,plate.y) do
	for gem,door in pairs(matches) do
	  if e.name == gem then
		findEntity(door).door:open()
		findEntity("invisible_teleporter_" .. counter).controller:activate();
		break
	  end
	end
  end
end
Your approach destroys the gems but will leave all other items on the plates. The author stated that any other items should be "lost" which is exactly what my suggestion will help accomplish. By activating the invisible teleporter that resides on top of each pressure plate, all items will be removed as soon as the door is opened. Plus, with my approach the author has more options at his disposal, such as proceeding to destroy the gems while actually returning any other items to the party by teleporting them to a proper location.

Your approach was only 50% useful but your attitude is 100% garbage. Consider lightening up some, being arrogant because you know a "script" is absurd. Some of us are here to have fun and share ideas. You get agitated any time someone offers a suggestion that you do not approve, but lately your silence is more valuable than your code. You may find this hard to believe, but Mod's will be made successfully without your guidance.
Slayer82
Posts: 303
Joined: Thu Feb 05, 2015 10:19 am

Re: Assistance in creating a proper floor_trigger puzzle

Post by Slayer82 »

Azel & minmay, both of your scripts have helped. For over a month now I have been trying to get it to work and now with your help I have.

On a side note, Frenchie was only trying to help. He/she were at least attempting to assist me when I was in need, so to me that's a grand gesture.

Azel, thanks for the help champ! You have made a small part of my game better and as a result have improved the entire mod.
Minmay, I would like to thank you too, but I feel it was harsh calling their work garbage. They were only trying to help, and as such have created a better community here on the Grimrock forum.
Mods - Isle of the Deranged & The Allure of Nightfall
http://grimrock.net/forum/viewtopic.php?f=23&t=9513
viewtopic.php?f=23&t=14762
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Assistance in creating a proper floor_trigger puzzle

Post by Azel »

Cool, better Mod's lead to better game days :mrgreen:

Glad you conquered your hurdle, buddy. One thing I would suggest as an entirely optional implementation, would be to eliminate the reference to the "name" of the gem and instead look for a specific gem ID.

Take the following line as an example:
if e.name == gem then

With this implementation, any Player can use the Console to Spawn a gem: Spawn("green_gem")

Behind-the-scenes, the Spawned gem will likely get the automatic ID of, green_gem_3; where the number at the end will be assigned based on how many other similarly named gems exist in your Mod. The Spawned gem will evaluate to "true" in the current version of the script as seen in this thread.

So if part of the experience of your Mod is to have the Player explore and discover a green gem, then removing the Players ability to Spawn a useable gem may be worthwhile. Referencing a unique ID will allow the pressure plate to activate based on the "real" gem(s), such as "green_puzzle_gem_1". Now the Player won't be able to do anything with their manually Spawned gem.

Thus the new line of code becomes:
if e.id == "green_puzzle_gem_1" then

It's a bit of extra leg work because multiple If/Then statements are required to determine which of the acceptable Uniquely Identified gem's is on the pressure plate. The primary benefit is that it eliminates Console cheating to help ensure a more solid gaming experience. Again, entirely optional but worth considering. Happy Mod'ing!
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Assistance in creating a proper floor_trigger puzzle

Post by minmay »

Azel wrote:Your approach destroys the gems but will leave all other items on the plates. The author stated that any other items should be "lost" which is exactly what my suggestion will help accomplish. By activating the invisible teleporter that resides on top of each pressure plate, all items will be removed as soon as the door is opened.
I was under the impression that the OP only wanted that so that the floor trigger could be triggered again. If they do want to destroy all items, it's a matter of moving one line (and obviously the timer is no longer necessary so you can just add a connector from the floortrigger):

Code: Select all

function checkPlate()
  local matches = {
    ["blue_gem"] = "mine_door_spear_79",
    ["green_gem"] = "mine_door_spear_80",
    ["red_gem"] = "mine_door_spear_81",
  }
  for e in beach_pressure_plate_6.map:entitiesAt(beach_pressure_plate_6.x,beach_pressure_plate_6.y) do
    for gem,door in pairs(matches) do
      if e.name == gem then
        findEntity(door).door:open()
        break
      end
    end
    if e.item then e:destroyDelayed() end
  end
end
Teleporting the item isn't destroying it :P
Azel wrote:Cool, better Mod's lead to better game days :mrgreen:

Glad you conquered your hurdle, buddy. One thing I would suggest as an entirely optional implementation, would be to eliminate the reference to the "name" of the gem and instead look for a specific gem ID.

Take the following line as an example:
if e.name == gem then

With this implementation, any Player can use the Console to Spawn a gem: Spawn("green_gem")

Behind-the-scenes, the Spawned gem will likely get the automatic ID of, green_gem_3; where the number at the end will be assigned based on how many other similarly named gems exist in your Mod. The Spawned gem will evaluate to "true" in the current version of the script as seen in this thread.

So if part of the experience of your Mod is to have the Player explore and discover a green gem, then removing the Players ability to Spawn a useable gem may be worthwhile. Referencing a unique ID will allow the pressure plate to activate based on the "real" gem(s), such as "green_puzzle_gem_1". Now the Player won't be able to do anything with their manually Spawned gem.

Thus the new line of code becomes:
if e.id == "green_puzzle_gem_1" then

It's a bit of extra leg work because multiple If/Then statements are required to determine which of the acceptable Uniquely Identified gem's is on the pressure plate. The primary benefit is that it eliminates Console cheating to help ensure a more solid gaming experience. Again, entirely optional but worth considering. Happy Mod'ing!
I legitimately cannot tell if you are serious or not, so for the benefit of other readers I will assume that you are.

You cannot eliminate players' ability to cheat, with the console or otherwise. The exported .dat file contains the entire source of your mod, and even a player's save game will contain virtually all useful information; there is no point in trying to fool people like this. Opening the door with the console, or teleporting the party with the console, etc. is just as easy as spawning a green gem with the console. The only thing attempting this sort of obfuscation will do is make debugging a pain in the ass, which is presumably not what you want.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Assistance in creating a proper floor_trigger puzzle

Post by Azel »

If a gamer is going to go as far as to extract the contents of the DAT file or review the contents within a Save Game file, then of course trying to eliminate cheating with script alone is futile. My recommendation has nothing to do with completely eliminating all forms of cheating. The point is simple: can a basic console command completely bypass major aspects of your game?

In your case, you don't draw a line between using the Console to Spawn an Item, using the Console to walk through a wall, or minimizing the game to extract a DAT file. That's fabulous, but there is still something to be said for doing a minimal level of quality assurance. I can tell from virtually every bit of code you publicize that you rarely, if ever, apply rules that improve the overall quality of the gaming experience. Referencing an Asset by name instead of by ID lets you write more compact code so that you can much more quickly showcase your Technical savvy. That rarely translates to a memorable gaming experience.

When playing Mod's, one can argue that "spawning" items isn't really much of a cheat, and it certainly shouldn't result in the making or breaking of a Mod. I know you disagree, I've seen your code. That doesn't mean it isn't worth the extra effort. Simply put, just because extracting a DAT file reveals a cheat, doesn't mean it's futile to reduce the overall impact of item Spawning via Console.

Cheat reduction isn't the only benefit of referencing Unique ID's either. Much more interesting decisions can be made when you know exactly which item a player is using (such as having the Hud Print a reaction to a green gem that came from a secret room under water vs the green gem that was dropped by the Undead boss vs doing nothing at all with a Spawned gem). It's all about quality game experience.

And I'm not trying to convince you of this at all. I was only sharing something I clearly said was optional, in case others share similar goals.
Post Reply