gui troubles

Blitz3D Forums/Blitz3D Programming/gui troubles

mtnhome3d(Posted 2008) [#1]
ok so i'm using the devil gui and it returns a string from the combo box that contains the list of the piece that i want to build. i also have a button that builds the selected piece but i need to switch from a string to an entity handle. here's the code. look at the select in the beginning and in the second if for ent%.
Function update_input()
Local temp_text$
Local temp_text2$
If GUI_AppEvent()=track_combobox
GUI_Message(track_combobox,"gettext",1)
Select temp_text
 Case "straight"
  temp_text2="track_straight"
  ent%=temp_text2
 Case "curve right"
  temp_text2="track_c_right"
  ent%=temp_text2
End Select

End If

If GUI_AppEvent()=build_button
t.track=New track
t\ent=CopyEntity (ent)
t\mat="metal"
EntityPickMode t\ent,2
EntityColor t\ent,81,81,81
PositionEntity t\ent,0,2,0
win_state="maximize"
End If
GUI_Message(mat_window,win_state,1)
End Function



bytecode77(Posted 2008) [#2]
your problem is to get the entity handle from the string. what does the string contain? does it contain the entity handle as many digits within the string or does it contain some sort of 'name' for the entity?
if that's the case, you need to set up a TYPE where your entity name and its handle is stored.

if i haven't understood your problem right, feel free to ask further...


mtnhome3d(Posted 2008) [#3]
if you look at the posted code it gets a string from a combobox and then determins a second variable from that. this second variable is a string also, but it contains the entitys name but in string format. like this "track_straight" now i have elsewhere told the program that track_straight is the name of an entity, and loaded a mesh with it. it is under a plane so as to be out of sight. after i determine the entity's name in string format i then need to convert to an int% but not sure how to name a variable the same as an strings contents.


Stevie G(Posted 2008) [#4]
Easiest way is to attach all your entities which are named "track_straight" etc... to a hidden, global TRACKpivot :

global TRACKpivot = createpivot()
hideentity TRACKpivot
loadmesh( "track_straight", TRACKpivot )
loadmesh( "track_c_right", TRACKpivot )


Then do this ..

t.track=New track
ent = findchild( TRACKpivot, temp_text2 )
t\ent=CopyEntity ( ent )
t\mat="metal"



mtnhome3d(Posted 2008) [#5]
ok so i try that and it tells me "entity is not a model" when it clearly is cause i could build it earlier with a button. so whats the not so easy way of doing this. i did it just like Stevie G's example. heres the code
If GUI_AppEvent()=build_button
t.track=New track
ent% = FindChild( track_pivot,temp_text2 )
t\ent=CopyEntity (ent)
t\mat="metal"
EntityPickMode t\ent,2     ;no error here
EntityColor t\ent,81,81,81 ;error here
PositionEntity t\ent,0,2,0
win_state="maximize"
End If



Stevie G(Posted 2008) [#6]
You seem ungrateful? It's clearly your model setup and nothing to do with the code!!!

I'm guessing your models are attached to a root pivot which you are naming rather than the mesh itself. Hence the reason you can set the pickmode but not the colour. Name the mesh, rather than the pivot in your modeller.

If you put these lines after "ent% = findchild( ) etc.. " you'll see that it isn't a mesh ..

Class$ = EntityClass$( ent )
debuglog Class
stop


mtnhome3d(Posted 2008) [#7]
it returns a pivot but shouldn't

i have no pivots except for the one that i parent everything to.


Stevie G(Posted 2008) [#8]
Clearly you do ... why would Blitz return a Pivot if this is not the case?! As I've already explained, the root node for your models seems to be a pivot and the track piece is attached to that. This would be what was done within your modeller, rather than Blitz.

If this works then I rest my case..

If GUI_AppEvent()=build_button
t.track=New track
ent% = getchild( FindChild( track_pivot,temp_text2 ), 1 )
t\ent=CopyEntity (ent)
t\mat="metal"
EntityPickMode t\ent,2     ;no error here
EntityColor t\ent,81,81,81 ;error here
PositionEntity t\ent,0,2,0
win_state="maximize"
End If