ID:155355
 
what would be the best way to make the location pick from 2 variables?

My Try:
var/MinX=10
var/MaxX=100
var/MinY=10
var/MaxY=100
loc=locate(rand(MinX,MaxX),rand(MinY,MaxY),2)


Any ideas?
mob
RandTeleport() // Random Teleport proc
var/list/L = list() // Define L to be an empty list
for(var/turf/T in world) // loop through all turfs in world
L += T // Add each turf to the list
src.Move(pick(L)) // Teleport to a random turf.


I'm not entirely sure what you mean but this is one way that I'd try to do it. This is the base for my spawning proc, modified it can teleport you within any region you wish.
In response to Lugia319
Lugia319 wrote:
> mob
> RandTeleport() // Random Teleport proc
> var/list/L = list() // Define L to be an empty list
> for(var/turf/T in world) // loop through all turfs in world
> L += T // Add each turf to the list
> src.Move(pick(L)) // Teleport to a random turf.
>

I'm not entirely sure what you mean but this is one way that I'd try to do it. This is the base for my spawning proc, modified it can teleport you within any region you wish.

this isnt even close to what i mean... i mean

proc/TornamentStartProc()
var/WarMap=pick("1","2","3","4")
var/MaxX
var/MaxY
var/MinX
var/MinY
switch(WarMap)
if(1)
MaxX=80;MaxY=80;MinX=20;MinY=20
if(2)
MaxX=180;MaxY=80;MinX=120;MinY=20
if(3)
MaxX=80;MaxY=180;MinX=20;MinY=120
if(4)
MaxX=180;MaxY=180;MinX=120;MinY=120
for(var/mob/M in TornamentEntries)
M.loc=locate(rand(MinX,MaxX),rand(MinY,MaxY),13)
M.TornamentOn=1
world<<"<font color=green><b>Server Info:</font> The Tornament has started on Map [WarMap]!"
global.TornamentStart=1
global.TornamentKillsNeeded=(global.InTornament*2)
In response to XxLucifersJesterxX
Calm down. The problem is you have the pick return a text string and your switch checks for a number.
In response to Lugia319
Lugia319 wrote:
Calm down. The problem is you have the pick return a text string and your switch checks for a number.

Calm down? i was jsut correcting you -.-;... Anyway, Example please?
In response to XxLucifersJesterxX
No example for you. You can figure this one out, it's very simple. Here's your answer in the form of a hint.

"1" != 1
In response to Lugia319
Lugia319 wrote:
No example for you. You can figure this one out, it's very simple. Here's your answer in the form of a hint.

"1" != 1

Nice way to be one of the rather useless people on BYOND, guess ill wait for Gakumerasara to get on or for someone else to actually decide to HELP instead of say whats wrong.
In response to XxLucifersJesterxX
XxLucifersJesterxX wrote:
Lugia319 wrote:
No example for you. You can figure this one out, it's very simple. Here's your answer in the form of a hint.

"1" != 1

Nice way to be one of the rather useless people on BYOND, guess ill wait for Gakumerasara to get on or for someone else to actually decide to HELP instead of say whats wrong.

If all you want is someone to write code for you, I suggest you hire a programmer.
Lugia has explained what is wrong quite adequately. You will learn by working to solve a problem. You will not learn by copy-pasting.

I will further demonstrate Lugia's point, in DM:
var/a = "1"
switch(a)
if(1)
world << "Rabbits"
if("1")
world << "Goats"

//The output will be Goats
In response to Murrawhip
Murrawhip wrote:
XxLucifersJesterxX wrote:
Lugia319 wrote:
No example for you. You can figure this one out, it's very simple. Here's your answer in the form of a hint.

"1" != 1

Nice way to be one of the rather useless people on BYOND, guess ill wait for Gakumerasara to get on or for someone else to actually decide to HELP instead of say whats wrong.

If all you want is someone to write code for you, I suggest you hire a programmer.
Lugia has explained what is wrong quite adequately. You will learn by working to solve a problem. You will not learn by copy-pasting.

I will further demonstrate Lugia's point, in DM:
> var/a = "1"
> switch(a)
> if(1)
> world << "Rabbits"
> if("1")
> world << "Goats"
>
> //The output will be Goats
>


i wasnt asking for someone to write code i was asking for what you did, AKA, an example so i can SEE what ive doen wrong, not an explanation of what i did that leaves me clueless.
In response to XxLucifersJesterxX
That was a rather rude way to talk to someone trying to help.

What Lugia319 is saying is that your procedure is botched because of the way you have your switch() proc.

proc/TornamentStartProc()
var/WarMap=pick("1","2","3","4")
var/MaxX
var/MaxY
var/MinX
var/MinY
switch(WarMap)
if(1)
MaxX=80;MaxY=80;MinX=20;MinY=20
if(2)
MaxX=180;MaxY=80;MinX=120;MinY=20
if(3)
MaxX=80;MaxY=180;MinX=20;MinY=120
if(4)
MaxX=180;MaxY=180;MinX=120;MinY=120


The root of the problem is this line.

 
var/WarMap=pick("1","2","3","4")


Your pick() will return "1","2","3", or "4"

However! You switch() doesn't have a return for any of those values!

Here's what you have,

    switch(WarMap)
if(1)
MaxX=80;MaxY=80;MinX=20;MinY=20
if(2)
MaxX=180;MaxY=80;MinX=120;MinY=20
if(3)
MaxX=80;MaxY=180;MinX=20;MinY=120
if(4)
MaxX=180;MaxY=180;MinX=120;MinY=120


I believe the point Lugia319 was trying to make was right there. And that was the root of the "hint."

"1" is not the same as 1. 1 is a number, and "1" is a text string. Your switch checks for a number, while the value itself is a text string!

In response to XxLucifersJesterxX
XxLucifersJesterxX wrote:
i wasnt asking for someone to write code i was asking for what you did, AKA, an example so i can SEE what ive doen wrong, not an explanation of what i did that leaves me clueless.

Clearly by posting in reply to your thread, Lugia's only intention is to help you. If you didn't understand his example of what you were doing wrong, you should probably have asked for further clarification instead of being rude.

Lugia319 wrote:
"1" != 1

Is a notation that would be familiar to many programmers. It says that the string 1 is-not-equal to the number 1.
In response to XxLucifersJesterxX
I've always found Lugia rather helpful, he was only telling you in the form of a hint because of how obvious your problem was.
In response to XxLucifersJesterxX
Lugia gave you exactly what you needed, you only had to ponder what ! meant in programming


example

if(!src.complete)

meaning not complete.