@Lark: Aside from trying to define a floor tile that spawns a floor_trigger... what [precisely] are you trying do do with the scripts?
(Step us through how your object should behave)
Modding infodump
Re: Modding infodump
It sounds like ScriptComponent isn't really suited for what you want to do, but if you want to define a ScriptComponent's source as part of the object definition you can do this:
I don't think you can load a file directly from the object definition unless you do this:
(The ScriptComponent's onInit hook is too late, the ScriptComponent has already been run by the time it's called).
Code: Select all
{
class = "Script",
source = [[function cow()
print("moo")
end
cow()]],
}
Code: Select all
{
class = "some other component",
onInit = function(self) self.go.script:loadFile("mod_assets/cow.lua") end,
},
{
class = "Script",
}
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Modding infodump
minmay: Thank you again. I can actually use what you have provided, I think.
I'm trying to create some "specialized" tiles that are self-contained so that no frameworks, extra scripts, plates, et cetera are required for the tiles to function correctly. Not that any of these things are bad, mind you, but I was trying to make the requirements quite simple so anyone could use them.
For example, a muddy tile that slows down the party or monsters that travel through it. I have some things working with seperate parts, but can I roll it all into a single object? If the party steps on a trigger, set the party's speed to slower until the trigger deactivates, then wait say one second and restore the party's speed. I'd like it to work for monsters too, but I've not checked to see if they can be slowed down or not. Yes, I know there are other ways to do this (and I probably don't know all of them or even most of them).
Another example would be a set of tiles that were slippery ice. If the party (or hopefully a monster) stepped onto the slippery ice, they would slide to the adjacent tile in the direction of movement without being able to stop. If the adjacent tile was also slippery ice, they would continue sliding until landing on the opposite shore or until they hit an obstacle that stopped their movement. Again, I know other ways I could do this with triggers and multiple scripts specifically configured for the environment I wanted, but can a set of stand-alone objects do the same things without the modder having to worry about such details?
Of course, my Windows 10 upgraded itself and crashed all administrative functions, so I have to rebuild it. No work on this for awhile... Thanks for listening and thank you all for your assistance!
Sincerely, -Lark
I'm trying to create some "specialized" tiles that are self-contained so that no frameworks, extra scripts, plates, et cetera are required for the tiles to function correctly. Not that any of these things are bad, mind you, but I was trying to make the requirements quite simple so anyone could use them.
For example, a muddy tile that slows down the party or monsters that travel through it. I have some things working with seperate parts, but can I roll it all into a single object? If the party steps on a trigger, set the party's speed to slower until the trigger deactivates, then wait say one second and restore the party's speed. I'd like it to work for monsters too, but I've not checked to see if they can be slowed down or not. Yes, I know there are other ways to do this (and I probably don't know all of them or even most of them).
Another example would be a set of tiles that were slippery ice. If the party (or hopefully a monster) stepped onto the slippery ice, they would slide to the adjacent tile in the direction of movement without being able to stop. If the adjacent tile was also slippery ice, they would continue sliding until landing on the opposite shore or until they hit an obstacle that stopped their movement. Again, I know other ways I could do this with triggers and multiple scripts specifically configured for the environment I wanted, but can a set of stand-alone objects do the same things without the modder having to worry about such details?
Of course, my Windows 10 upgraded itself and crashed all administrative functions, so I have to rebuild it. No work on this for awhile... Thanks for listening and thank you all for your assistance!
Sincerely, -Lark
Re: Modding infodump
A slowing "tile" that only slows the party can easily be implemented as a standalone object using only FloorTriggerComponent, provided you do not use PartyComponent:setMovementSpeed() elsewhere in your mod, although it will be inefficient. You still don't need a ScriptComponent for it - a ScriptComponent isn't even useful for it.
A slippery tile cannot be implemented properly without using PartyComponent hooks.
A slippery tile cannot be implemented properly without using PartyComponent hooks.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Modding infodump
Although it's only a simple example of what I'm playing with, why not? 1) The party steps on tile activating the trigger component, 2) the party speed set to .6 (or whatever) by onActivate, 3) the party leaves the tile and the triggers onDeactivate setting the party speed back to normal after a short delay (which is the only part that I don't have working in a self-contained object.) It works perfectly. The self-contained part is for convenience of the mod maker and I don't care if it uses a script component for the delayed call or if it just raises another condition after the timer expires. I'm playing with getting the delay out of a timer component since I'm having trouble with delayed calls in the controller component.minmay wrote:a ScriptComponent isn't even useful for it.
If someone has done something similar, it would be nice to know. After all, these forums are supposed to be about sharing ideas, giving help, and getting help. It's all about learning and trying to stretch the limits and trying out your ideas. -Lark
Re: Modding infodump
I'm still not seeing how adding a ScriptComponent to every instance this object is useful in this situation. delayedCall() doesn't ever interact with ScriptComponent directly, it only interacts with ControllerComponent and ScriptControllerComponent (delayedCall is just a connector event that happens after a delay). So if you are going to add an extra Component to all of these objects to get a delay, you might as well make it a ControllerComponent (and have "delayedCall(self.go.id,1,'stop')" or whatever in the FloorTriggerComponent.onDeactivate hook) or a TimerComponent (that resets the party's movement speed in its onActivate hook).Lark wrote:Although it's only a simple example of what I'm playing with, why not? 1) The party steps on tile activating the trigger component, 2) the party speed set to .6 (or whatever) by onActivate, 3) the party leaves the tile and the triggers onDeactivate setting the party speed back to normal after a short delay (which is the only part that I don't have working in a self-contained object.) It works perfectly. The self-contained part is for convenience of the mod maker and I don't care if it uses a script component for the delayed call or if it just raises another condition after the timer expires. I'm playing with getting the delay out of a timer component since I'm having trouble with delayed calls in the controller component.minmay wrote:a ScriptComponent isn't even useful for it.
I'm also curious what the intent of this timed behaviour is. Is it supposed to reset the party's movement speed at the end of the movement "animation"? If so, then you need to account for the party becoming encumbered or underwater, which they can do during the move (or become unencumbered during the move, or swap between the two rapidly), meaning the amount of time needed to complete the move could be anything within a certain range and the exact value within that range is unknown until the move is completed. Meaning that you can't compute it in advance, meaning that this approach won't work for that.
Or is it supposed to stick with the party for a while after they leave the tile? In that case, how do you deal with the party stepping on several of these tiles in rapid succession? You'll pile up delayed calls if you try to make that completely self-contained, and end up with the party's speed getting reset to full while they're still standing on one of the muddy tiles. You'll need some common ground between all these tiles for that to work, and an external script or an extra component on the "party" object is really the only reasonable way to do that.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Modding infodump
minmay: Okay, I see. Thank you for taking the extra time to help me yet again. You're quite amazing, you know. Thanks for the information on creating smooth 3D models without sharp edges too (or something like that). I'll be searching for that again and hopefully produce a few decent models eventually once I understand what you're telling everyone. -Lark