New to RMMZ and java...need help with respawn timer please.

Hello everyone!

I'm a total noob with both MZ and coding....coding especially so I'm terrible with terminology.

I'm trying to set up a mining system where the nodes respawn after a certain amount of time. My goal is/was to do it using as few global variables as possible. I tried to prod some useful information from chatGPT but I don't know if it helped or made it worse lol. Also, I attempted to set up Eli's self variable plugin...but couldn't get it to work.

I have a working global clock that ticks up every second at the moment, but can't get anything to work correctly beyond that...my node respawns instantly.

Any help would be truly appreciated 😎
RPG Maker is not a ready-made engine; you first need to understand how it works.
It's also necessary to understand Switches and Variables for basic game functions, such as only being able to talk to an NPC once.

Another issue is that it doesn't directly involve programming, by learning only events, you can create different types of systems in your game.

One observation: no software based on web languages uses JAVA, check the engine's manual, the RPG Maker API was written in Javascript.
Please follow read and follow the template, it has READ in all caps and three exclamation marks for a reason:


It's hard to gauge what the issue is, but if you are a complete noob I would suggest that you first follow the inbuilt tutorial (accessible from Help) before doing anything fancy.
I already have enough understanding to make maps, events, control self switches, variables, animations etc but i'm not sure what is possible within the engine. My biggest problem is scripting and terminology tied to javascript and MZ.

I'll try be more specific with the issue.

Using EliMZ_SelfVariables with EliMZ_Book, but they don't appear to be working.

I'm trying to set this up using the lowest # of variables possible. I want ore nodes to respawn every 20ish minutes or so and not reset when player leaves the map and returns. I have a common event that ticks up a globalTime variable every 60 frames (1 second).

I'd like to have a way to set a timestamp variable of when the node was harvested without a global variable for each node.

ChatGPT had me set up this on page 1 and 2. I semi-understand what its trying to do, but not sure if it's possible or remotely correct.

Page 1 before setting self switch on (to make event despawn), +10 seconds for testing:

var index = $gameMap.mapId() * 1000 + this.eventId();
$gameVariables.setValue(index, $gameSystem._globalTime + 10);

page 2 to respawn the event:

var i = $gameMap.mapId() * 1000 + this.eventId();
if ($gameSystem._globalTime >= $gameVariables.value(i)) { $gameSelfSwitches.setValue([$gameMap.mapId(), this.eventId(), "A"], false);
}

I'm fairly certain that I can accomplish what I'm aiming for if I set up a variable for each node for the time in seconds it was harvested plus 1200 seconds, then respawn....but I was hoping for a more efficient way without blowing up my brain.
I haven't followed this tutorial myself, so not sure if this does exactly what you want or how easy it is to follow, but I do recall @Trihan wrote a tutorial for respawning resources.

He might be able to elaborate more.

ChatGPT had me set up this on page 1 and 2.
A few things to keep in mind here;
I would not follow ChatGPTs advice unless you are skilled enough with the engine to recognize what it is doing and how to correct any errors it may produce.
But if you are going to use it, it's a chat bot; just ask it to clarify what it means and why it's doing what it's doing.
But I think many people here would prefer you just come to us first instead of asking a chat bot which may produce inefficient or incorrect results.
I tried chatgpt, it works for me!

--removed--
My tutorial does involve some script code, but it's largely self-maintaining so you should be able to follow it without too many issues.

@mrcopra do not distribute AI generated resources. Doing so is against the rules.

Original thread: https://forums.rpgmakerweb.com/threads/new-to-rmmz-and-java-need-help-with-respawn-timer-please.180848/