Terrax Lighting system

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
$gameMap.events() is a default function in rpgmaker to return an array of events for the current map. You should be able to access it.


Also when wanting to access $dataMap.events, you can access from the event object returned from that $gameMap.events() array with the event() function.


 


eg. the function in the event is:



Game_Event.prototype.event = function() {
return $dataMap.events[this._eventId];
};


So you can reference the events that have been created in the $gameMap object and still get the $dataMap.events info (as my spawn plugin changes this function to be able to access the correct map for this data).


 


Hope this makes sense and helps.


 


So, what should I do to make my game work fine?
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
$gameMap.events() is a default function in rpgmaker to return an array of events for the current map. You should be able to access it.


Also when wanting to access $dataMap.events, you can access from the event object returned from that $gameMap.events() array with the event() function.


 


eg. the function in the event is:



Game_Event.prototype.event = function() {
return $dataMap.events[this._eventId];
};


So you can reference the events that have been created in the $gameMap object and still get the $dataMap.events info (as my spawn plugin changes this function to be able to access the correct map for this data).


 


Hope this makes sense and helps.


 


Not yet.. i can access $gameMap.events(), but its always empty ($gameMap.events.length = 0).


Lets take this piece of code :


for (var i = 0; i < $dataMap.events.length; i++) {
if ($dataMap.events[i]) {
var note = $dataMap.events[i].note;
   }
}





How would i change that to read the Game_events instead of the datamap?
 
Last edited by a moderator:

Galv

Veteran
Veteran
Joined
Oct 1, 2012
Messages
1,273
Reaction score
1,525
First Language
English
Primarily Uses
RMMZ
var eventList = $gameMap.events();
for (var i = 0; i < eventList.length; i++) {
if (eventList) var note = eventList.event().note;
}




Make sure you're using $gameMap.events() and not $gameMap.events as it is a function that needs to be executed () to return the array of events.


EDIT:


Here's your plugin modified as a quick example:


http://www.mediafire.com/file/ku2unldbchyi5cn/TerraxLighting-_Galv_Edit.zip


- I did a quick find/replace to change the references for $dataMap.events to $gameMap.events()


- I changed references to $dataMap.events[x].note to $gameMap.events()[x].event().note


- I changed references to the event's x,y to use the event's _realX,_realY


- From the quick test in the demo it appears to work
 
Last edited by a moderator:

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
var eventList = $gameMap.events();
for (var i = 1; i < eventList.length; i++) {
var note = eventList.event().note;
}




Make sure you're using $gameMap.events() and not $gameMap.events as it is a function that needs to be executed () to return the array of events.



That example was a big help!


converting the script to gameMap.events(), should be an update soon!
 
Last edited by a moderator:

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
Thank you two SO much ;)
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
var eventList = $gameMap.events();
for (var i = 0; i < eventList.length; i++) {
if (eventList) var note = eventList.event().note;
}




Make sure you're using $gameMap.events() and not $gameMap.events as it is a function that needs to be executed () to return the array of events.


EDIT:


Here's your plugin modified as a quick example:


http://www.mediafire.com/file/ku2unldbchyi5cn/TerraxLighting-_Galv_Edit.zip


- I did a quick find/replace to change the references for $dataMap.events to $gameMap.events()


- I changed references to $dataMap.events[x].note to $gameMap.events()[x].event().note


- I changed references to the event's x,y to use the event's _realX,_realY


- From the quick test in the demo it appears to work





Lol.. that was fast


Ill take a look at the changes and implement them in a new update (already had some other new features as well)
 
Last edited by a moderator:

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
I've tested it a little bit more, but light remains where event was spawned after unspawning :(


Hope this exhaustive bug reporting doesn't bother.
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
I've tested it a little bit more, but light remains where event was spawned after unspawning :(


Hope this exhaustive bug reporting doesn't bother.
No, no.. please keep on testing, nothing is more frustrating then updating and finding out half an hour later that there is a bug that needs another update.


I'm still working on the script, Galv realy helped a lot and i think i can remove two script overwrites.. Thats realy realy nice because it means less problems with other addons.


I haven't looked at the event spawning script yet, but for unspawning events the 'killswitch' option was designed. You can set it in the options of the plugin. If you set the Killswitch to 'C' then throwing selfswitch 'C' on an event will turn of the lights on that event. If that fixes the probem, let me know because i worked out the other kinks and ill update the script.


Time for bed, i will upload the new version tomorrow, if no other bugs pop up :).
 
Last edited by a moderator:

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
New version (1.4.2) now available


http://mvplugins.com/plugin/Terrax/Terrax%20Lighting%20System


or


https://github.com/Terraxz/TerraxLighting


Due to Galv's amazing help, the plugin now is compatible with spawned events. I also managed to cut two overwritten core-scripts that could potentialy cause problems with other plugins.


Added : Compatiblity with spawned events.


Added: The in-game configuration menu now contains a menu item to turn off the lighting script. This was done because some low-end machines have problems with the rendering, players can now self choose to turn off the script if required. If you do not want the extra menu option you can set it in the plugins settings.


Terrax
 
Last edited by a moderator:

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
For some reason, Galv's edit works fine in my computer, but your new version not :(  
 

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
Any errors? What's not working?
The entire plugin. The dark mask doesn't appear and my dungeons are totally bright and "unmysterious" : (
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
The entire plugin. The dark mask doesn't appear and my dungeons are totally bright and "unmysterious" : (
Hmm.. i think i slipped in a very small bug in the new options menu.. the script seems to default to 'off' when you install the script.


Start a game.. in the menu go to options -> turn 'lighting effects' to on.
 

ABSTRVCT

- Enlightened -
Veteran
Joined
Nov 19, 2016
Messages
38
Reaction score
1
First Language
Spanish
Primarily Uses
Solved! Thank you ;)
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
I've updated version 1.4.2 so that that the lighting option is on by default when you install it.
 

KaYsEr

Koruldia
Veteran
Joined
Mar 14, 2014
Messages
264
Reaction score
481
First Language
French
Primarily Uses
RMMV
Thanks Terrax!
When I open the archive I can see 2 plugins, I know one is for compatibility reasons (for users with outdated MV) but it's hard to tell which one.


Both of them work for me.  :D
One has the regular name and the other has _Pixi3 in the name, but if I remember well MV went from Pixi2 to Pixi4 directly, so it could add an extra layer of confusion.
Just to be sure, which one is for regular "MV updated" (now 1.3.4) users? :)
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
Thanks Terrax!
When I open the archive I can see 2 plugins, I know one is for compatibility reasons (for users with outdated MV) but it's hard to tell which one.


Both of them work for me.  :D
One has the regular name and the other has _Pixi3 in the name, but if I remember well MV went from Pixi2 to Pixi4 directly, so it could add an extra layer of confusion.
Just to be sure, which one is for regular "MV updated" (now 1.3.4) users? :)
Ah, i didn't know MV went from pixi2 to pixi 4..


Pixi3 will run on all version, but it will throw some errors in the console panel that some functions are deprecated.


When you run the updated MV scripts, TerraxLighting.js will not throw those errors.


Basicly it's easy.. install TerraxLighting.js. If your game instantly throws an error, use TerraxLighting_Pixi3 instead.


But seeing that its confusing, ill describe it better next time.
 
Last edited by a moderator:

luiscesjr

Veteran
Veteran
Joined
Jun 26, 2014
Messages
117
Reaction score
11
First Language
Portuguese
All i can think of is that you made an error with the switches, can you link the common event your using?
Sorry for the delay man, I don't see where I got it wrong but, here take a lok at my common event:


◆Se:Lanterna é LIGADO
  ◆Interruptores de controle:#0247 Lanterna = DESLIGADO
  ◆
:Mais
  ◆Interruptores de controle:#0247 Lanterna = LIGADO
  ◆
:Fim
◆Se:Lanterna é LIGADO
  ◆Comando de plug-in:Flashlight on 8 12 #FFFFFF
  ◆Texto:Nenhum, Janela, Meio
  :     :Você ligou a lanterna. 
  ◆
:Mais
  ◆Comando de plug-in:Flashlight off
  ◆Texto:Nenhum, Janela, Meio
  :     :Você desligou a lanterna.
  ◆
:Fim


Sorry it's in portuguese, I'm a bit reluctant to put it in english and get some part of the project wrong,


so if you don't undertand I will try to translate it better, but it's quite self explanatory, just as your demo but with different words


and switches. On the If, it's the same switch 247.


Se = If
 

Zaen

Find Me on YouTube
Veteran
Joined
Nov 15, 2016
Messages
115
Reaction score
30
First Language
English
Primarily Uses
Awesome, thanks for the update.
 

Terrax

Veteran
Veteran
Joined
Oct 30, 2015
Messages
304
Reaction score
226
First Language
English
Sorry for the delay man, I don't see where I got it wrong but, here take a lok at my common event:
Question.. did you perhaps set the player-radius to 0? Because that will also disable the flashlight.


If you only want the flashlight set the radius to 1, this will show the flashlight without showing a globe of light around the player.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 3)

Latest Threads

Latest Posts

Latest Profile Posts

Officially not a mod anymore. Thanks for the many years!
Thinking if i should post on the classifieds section...
Made another plugin showcase video! :kaojoy:
(Plugins and details inside the description of the YouTube video.) :LZScheeze:
Ami
Castle is my Biggest Fear :kaodes:. I just Managed make Part by Part (like the Entrance only),not the Entire Castle like in the RM Sample...
This video really speaks to me...

Forum statistics

Threads
104,373
Messages
1,005,905
Members
135,894
Latest member
EnriX
Top