Euflorium: The Eufloria Community
Eufloria => Eufloria Classic => Eufloria Classic Mods => Topic started by: Alex on July 14, 2010, 09:10:40 PM
-
Just putting in "OnAsteroidSelected" and "OnMouseLeft/RightClicked" :o
-
If you click on an Asteroid, OnAsteroidSelected(ID) will be called. Otherwise, OnMouseLeftClicked(x,y) will be called on a left mouse click and OnMouseRightClicked(x,y) will be called for a right click. x and y are world coordinates of the mouse cursor.
-
With coordinates do you mean of the screen? or of the level map?
Like this? :
function LevelLogic()
OnAsteroidSelected(1 :OnMouseLeftClicked(2000,-8000)
End
-
map coords yeah.
-
Once again, this will open many new possibilities for level design. :>
-
Will it? I can't think of many, but then I didn't think of making a gravity engine, so...
-
you can without gravity engine
if you have a asteroid that is very far away?
-
Oh, well, lets see...
You could create a map where clicking on a blank bit of space creates an asteroid there. :>
You could create a map where clicking on a blank bit of space creates an ever-increasing gravity well at that location, peaking after 10 seconds before subsiding again. Imagine what that would do in a map like Big Bang :>
You could also create a map where clicking on the background causes the background colour to change. Why is this useful? I haven't the slightest idea. :> But I'm sure it will come in handy for something !
What else, hmm.. you could have a map where you control a single, uber-tough Laser Mine. When you click somewhere, the mine's "asteroid" (the one it is orbiting) moves - drifting toward the clicked location - although the player wouldn't see this as it has a radius of 0. All the player would see is the mine moving about. :> You could build an arcade-style see-how-many-seedlings-you-can-flatten level.
Imagination ftw !
-
You could build a variation of the comet level where the "lift" asteroid moves to a different location when you click on it.
You could draw your own HUD around an asteroid with clickable buttons... we're not completely there yet but I Can add things like getting the mouse's screen coordinates, getting the screen's size, core mouse down and mouse up events that fire ragardless of what you click on, etc etc
-
You could actually build an in-game level designer with the likes of this.
You can use the Draw commands, and the Text Draw commands, to render a menu system.
Then, you can have the game add in mechanics or asteroids simply by letting the player click on stuff. :>
-
All we'd need is to be able to save levels.
-
Oh, this will also mean that designers can make tools like the long-called-for rally point, and use them in their levels.
Upon clicking a button, the script is activated. The next asteroid the player selects is the rally point, and all their seedlings start drifting towards it (the metric shortest-path system used for Infected AI would work fine for this). Clicking the button a second time toggles the rallying behaviour off again.
-
Oh, this will also mean that designers can make tools like the long-called-for rally point, and use them in their levels.
Upon clicking a button, the script is activated. The next asteroid the player selects is the rally point, and all their seedlings start drifting towards it (the metric shortest-path system used for Infected AI would work fine for this). Clicking the button a second time toggles the rallying behaviour off again.
Wouldn't it be more accuarte to say "This means i can make a bit of code that does this and the rest of the community can use the template i provide them" :)
-
Judging by some of the posts lately I would think some designers will be able to start building their own mechanics pretty soon.. :>
-
Working on it. If I see the word 'check' one more time I think I'll scream.
Oh, no, there it is! *AAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHH!!!!!!!!1!!!!!!!1!!11!!!!!!!!!!one!!!!!!*
-
function OnAsteroidSelected()
--stuff here
end
Doesn't seem to work. It either does nothing, or crashes the game, depending on what I put in it.
-
That's because he's just putting it in, I think..? It's not live yet..?
-
Well, the patch is uploaded, and the list of fixes/new stuff includes it, so I thought it would be working now.
-
should be
function OnAsteroidSelected(id)
-- where id is the id of the asteroid that was selected
end
-
How do I use that for any asteroid, so that it is always called when any asteroid is clicked?
Say I wanted to make a box appear that said "You clicked on asteroid " and then displayed the asteroid's id?
-
@ Pilchard
Wouldn't that be like:
function OnAsteroidSelected(id)
MessageBox("You have clicked on asteroid "..id.."")
WaitDialog()
end
I dunno. Maybe I am right, but that's basically how it works.
Isn't it? :P
-
Yeah. so like if you wanted asteroid 13 to do something you'd do
function OnAsteroidClicked(id)
if id == 13 then
-- do some funky stuff
end
end
-
He means OnAsteroidSelected, not OnAsteroidClicked :>
-
No, OnAsteroidClicked is better for what I want to do. I didn't know that one existed.
So, let me get this straight: OnAsteroidClicked() will be called any time an asteroid is clicked, even if that is the one you last clicked on and you have the planting menu open, OnAsteroidSelected() will be called when you click on an asteroid that has no menu coming from it.
Right or wrong.
Or did you mean that Alex meant OnAsteroidSelected()?
Right, I NEED OnAsteroidClicked(). Well, not NEED, but it would be useful.
-
Assuming it was a typo on Alex's part and there aren't two distinct functions, the way I would solve this is with the function OnMouseLeftClicked. This returns X and Y, which are the coords that the mouse was left-clicked at.
Then you would run a For loop, to check all of the asteroids.
On each asteroid check, use some maths to check if X and Y fall within the bounds of that asteroid - you can calculate this based on the asteroid's coords (x and y) and its radius.
Bit complicated, but it IS possible to do this. It would mean that every time the mouse is left-clicked somewhere in the level, the code would run, and check if an asteroid was clicked on. It would not matter if it was already selected.
-
Yeah, that would work, but I've thought of a better way. Thanks anyway.
I still think that OnAsteroidClicked would still be good.
-
Yeah, that would work, but I've thought of a better way. Thanks anyway.
Willing to share? :> I can't think of an easier way so I'd be curious what you've come up with :>
-
Oops. It was kind of ambiguous wasn't it. I meant I've thought of a better way to do what I'm working on. Sorry.
Is there any way of drawing something so that it always has the same position and size on the screen, like it was drawn on the camera lens? And also to check if that something (eg. a square) was clicked on?
-
I'll put in some stuff for that.
You could do it by getting the camera's position and then dividing the size of your objects by the camera's zoom - that'd make it the right size and put it relative to the camera. Less than ideal though.
-
So, draw it as if it was to be relative to the world, then divide lengths and positions by the zoom level of the camera?
-
Yeah, think so - give it a go. Might be multiply...
-
No. Draw it related to the position of the camera, NOT the world.
So for example if you GetCameraPosition and it is 2000, 2000, you know that is where the camera is looking.
If you want your drawing to appear on the right of the screen, you would make the drawing origin at (X + 5000) / GetCameraZoom, Y / GetCameraZoom
I think that should work. Let us know if it doesn't. :>
-
function LevelDraw()
scale = GetCameraZoom()
xpos = GetCameraX()
ypos = GetCameraY()
DrawLine((xpos+5000)/scale, ypos/scale, (xpos+5100)/scale, ypos/scale, 0,0,0,0.99,0,0,0,0.99,3)
end
Doesn't work, nor does multiplying.
-
It probably does, it's just that your line is 5000 pixels off to the right...
-
Yeah my bad, 5000 is probably a bit much. Try something more conservative like 100 I guess.
-
Here's the correct code, but at the moment the camera returns negative values for its position
function LevelDraw()
scale = GetCameraZoom()
xpos = GetCameraX()
ypos = GetCameraY()
x1 = 0
y1 = 0
x2 = 200
y2 = 50
DrawLine(xpos + (x1)*scale, ypos + y1*scale, xpos + (x2)*scale, ypos + (y2)*scale, 0,0,0,0.99,0,0,0,0.99,3*scale)
end
So you will need to do
xpos = -GetCameraX()
ypos = -GetCameraY()
until I fix it. Which I have, so in the next update this will be fixed.
-
But I'll put in screen drawing stuff anyway.
-
There, it's done. Next update this code will let you draw a filled box on the screen by dragging with the left button:
drag=0
mx=0
my=0
function OnMouseLeftDownScreen(x,y)
drag=1
mx=x
my=y
end
function OnMouseLeftUpScreen() -- can include x,y as parameters here if you need them
drag=0
end
function ScreenDraw()
if drag == 1 then
mx2=GetMouseScreenX()
my2=GetMouseScreenY()
DrawBox(9,8,mx,my,mx2,my2,1,1,1,1) -- (texture ID, border, left, top, right, bottom, r, g, b, a)
end
end
-
Awesomez :>
-
Yeah, but how do I draw other stuff to the screen, through LUA. Like drawing liens in the world, perhaps DrawLineOnScreen(x1,y1,x2,y2,r1,g1,b1,a1,r2,g2,b2,a2)?
I have everything for a rallypoint system set up, when the next update comes, regardless of that last request. Should have it working as soon as the next patch happens.
-
If you want to draw stuff on the screen, rather than in the world, use the code in my post above e.g.
function LevelDraw()
scale = GetCameraZoom()
xpos = -GetCameraX()
ypos = -GetCameraY()
x1 = 0
y1 = 0
x2 = 200
y2 = 50
DrawLine(xpos + (x1)*scale, ypos + y1*scale, xpos + (x2)*scale, ypos + (y2)*scale, 0,0,0,0.99,0,0,0,0.99,3*scale)
end
will draw a line from 0,0 (screen centre) to 200 pixels to the right and 50 pixels down.
-
Oh, okay. I could probably do the rallypoint now, but it'll be much better from the next patch. Working on it.
-
OK. I will probably wait at least a few days to see if there are any other issues with the latest one, and see if anyone comes up with any really cool ideas, and see if I can add a few more of the things people want...
-
Wow, Alex, this is what I call (a) responsive developer(s). You guys rock!
-
Nearly done, just fixing the button.
-
Hey, you guys could make the right click function into a way to use an ability, like say after a cooldown period, you can say call in a laser mine or something at the location where you click, or add a boost to seedlings or asteroid traits or something.
-
All we'd need is to be able to save levels.
I was looking through the Programming in Lua guide you linked here (http://"http://www.dyson-game.com/smf/index.php?topic=212.msg1978#msg1978") and noticed that Lua has an I/O library (http://"http://www.lua.org/pil/21.html") built into it. I just gave it a quick test and found that you can indeed create, read and write to files in a Eufloria map!
So, who wants to make a Visual Level Editor level? ;D
-
haha wow that's awesome I didn't even think of trying that. Like you could use the left and right click functions to move the asteroids around where ever you want them. I feel like it would need a custom menu for it though to save and load levels.
-
The real question is when is someone going to recreate Microsoft Paint in Eufloria!
I want a line draw tool!!
-
I want a line draw tool!!
It'd be do-able after the next update, I reckon. Heck, you could do it now, even. It would just be less user friendly.
That's my next project then - a line drawing tool. It's just a small change to the rallypoint code.
-
I was kidding :P
But hey, it proves a point... ;)
-
I know, but it's something to do.