inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:02:29 GMT -8
Yes I do
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:10:54 GMT -8
ok so if you select one of them and hit the insert button, it will push it into the javascript area. if you do something like
var myList=
then insert the variable for the autoform after it
var myList=plugin.settings.....autoformname
you have a quick association so you dont have to type or insert it again
since myList is now an array, you can access it like I said before.
myList[N].title or myList[N].url
or myList.length
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:12:35 GMT -8
var suvImg=proboards.plugin.get('survival_images').settings.image_testing
like that then?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:13:31 GMT -8
image_testing is the name of the autoform right?
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:17:00 GMT -8
Yep that's right
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 12, 2013 4:18:17 GMT -8
WormopolisLittle off topic here, but am interested in how you created the seed. Math isn't my strong point when it comes to programming, so am keen on how you went about it (not by seeing code as such, but just your own explanation, your thought process when you were working on that).
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:18:56 GMT -8
excellent. so now suvImg is an array. you can treat it like a javascript array.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:19:18 GMT -8
WormopolisLittle off topic here, but am interested in how you created the seed. Math isn't my strong point when it comes to programming, so am keen on how you went about it (not by seeing code as such, but just your own explanation, your thought process when you were working on that). in the weather code?
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:20:31 GMT -8
right so then would I just do this to get the random url like this:
Math.floor((Math.random()*suvImg));
Or would that need to be given a variable?
-sorry javascript coding beyond simple if its this url do this' isn't a strong point-
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 12, 2013 4:25:33 GMT -8
WormopolisI think so. I haven't looked at the code for your plugin, but I read in an earlier post of yours that you create a seed based on the time. I assume it's a daily seed, but am wondering how you went about doing it. I'm curious as I've been reading related material (i.e Random Seeds) to do with seeds (mostly with Math.random).
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:26:58 GMT -8
suvImg.length is the length of the array. you need that in there.
the rest is perfect. it gets you a random float between 0 and 1, times the length, and then drops the decimal to get just an integer. just assign what you have there to a variable.
that integer becomes the indices for access to a single array element
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:30:38 GMT -8
Oh! I need to add ; to the end of javascript lines that aren't commented don't I? and this is what I have so far
//Variable that contains the images here from autoform var suvImg=proboards.plugin.get('survival_images').settings.image_testing; //math.random randomizes images and will be used here var suvRandom=Math.floor((Math.random()*suvImg.length)); //Append image to div $('div#survivalImg').append($('<img src=" output here " />'));
Does this all look okay and how would I then put the output as an image? Would it be just calling the suvRandom or?
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:40:15 GMT -8
WormopolisI think so. I haven't looked at the code for your plugin, but I read in an earlier post of yours that you create a seed based on the time. I assume it's a daily seed, but am wondering how you went about doing it. I'm curious as I've been reading related material (i.e Random Seeds) to do with seeds (mostly with Math.random). well for the weather code I couldnt really do a real random (technically speaking there is no true random number generator.. they all are fake.. but I digress). so what I needed was a pseudo-random number that would be the same for everyone that viewed the page. that way the image that was pulled from the array would be the same for everyone, especially if they used the weather that day in a story. so I started with a date.getTime() that returned a large number of milliseconds since jan 1970. great. dont need that specific, so I divided that number down to the day time / (1000*60*60*24) THAT number would be the same for everyone. well everyone in the same day, but people in austrailia are just funny. you can actually select an option to account for timezones, but again.. digression but now I have a large number and I need it to be sorta random Math.floor(Math.abs(Math.cos(dayseed)*dayseed)); the cosine function is sorta random, -1 to 1, multiplied by itself gives a small to large number, remove the sign, drop the decimal so I still basically have a variable sized number, that I do this to: dayseed%weatherarray.length so the modular function returns 0 to n-1 of the array length. which I use to access a specific image. so as I said, pseudo-random. and yes I probably could have done some more math functions in there to ensure no patterns emerge.. but Im not plotting space trajectories with this.. it makes it sunny or rainy on a message board.
|
|
inherit
King Oligochaete
126470
0
Feb 24, 2021 12:23:15 GMT -8
Wormopolis
Stop rating plugins with 1 star that dont deserve it.
20,002
June 2008
tbserialkillers
Wormo's Mini-Profile
|
Post by Wormopolis on Aug 12, 2013 4:42:54 GMT -8
Oh! I need to add ; to the end of javascript lines that aren't commented don't I? and this is what I have so far //Variable that contains the images here from autoform var suvImg=proboards.plugin.get('survival_images').settings.image_testing; //math.random randomizes images and will be used here var suvRandom=Math.floor((Math.random()*suvImg.length)); //Append image to div $('div#survivalImg').append($('<img src=" output here " />')); Does this all look okay and how would I then put the output as an image? Would it be just calling the suvRandom or? suvRandom becomes the integer you use to access the specific suvImage array element and in that append, you have to break out of the single quotes if you want to use variables. you cant use variables inside '<img src="' + javascript stuff + '">'
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Aug 12, 2013 4:45:57 GMT -8
//Variable that contains the images here from autoform var suvImg=proboards.plugin.get('survival_images').settings.image_testing; //math.random randomizes images and will be used here var suvRandom=Math.floor((Math.random()*suvImg.length)); //Append image to div $('div#survivalImg').append($('<img src="'+suvRandom+'" />'));
Like this? As it's not showing an image - just the no image symbol ((Now what have I forgotten!))
|
|