GameScript question...
Blitz3D Forums/Blitz3D Userlibs/GameScript question...
| ||
| I was looking at the GameScript (http://www.blitzbasic.com/Community/posts.php?topic=69531) example1.bb (the prime numbers example), is there a way for the script (.gs/.gsx file) to reference objects (variables, types, etc…) that exist in the main program. For example, let’s say I have an enemy tank type in the main program and I wanted to write an AI routine in the script to control the tank. Is there a way to control enemy tank type from within the script. Thanks for any help. |
| ||
| Thats a good question, I wanted to know the exact same thing as well, so it would be handy to have an example of this. |
| ||
| why not just write a wrapper function and add that to the gamescript_functions.bb? something like:
function setTankProperty( tankid%, field$, value$ )
t.tTank = object.tTank( tankid )
if t = null then return false
select field
case "hitpoints"
t\hitpoints = value
case "something_else"
t\something_else = value
default
return false
end select
return true
end function
seems simple enough... |
| ||
| Thanks for your response. I am trying to follow your example but my script... <start script> Type Ship Field total:Int EndType Global car:Ship car = New Ship car.total = 9999 <end script> keeps giving me an "Object does not exist" error. Any ideas why this is? |
| ||
| ok, first: i think there's a typo in GameScriptVM.bb at line 1019: "var\Thread = Thread" should be "obj\Thread = Thread" I THINK! at least the script runs then. BUT second: im continously getting errors when accessing type fields. even the example from the manual fails: Type Vehicle Field Speed:Float EndType Local Car:Vehicle Car = New Vehicle 'Create a new instance of Vehicle and store it's pointer in Car Car.Speed = GetSpeed(Car) + 10 Function GetSpeed:Float(v:Vehicle) Return v.Speed EndFunction ill post that in johns original thread, maybe he knows a solution... btw: interesting that nobody used that feature yet and found that bug, since its quite obvious and reproducable o.O |
| ||
| Ik think i may may help you here. First chang line Car = New Vehicle --> in Car.Vehicle = New Vehicle And line Car.Speed = GetSpee... --> in Car\Speed = Getspee.. Dont use the local assing for the car before you assing the type to your variable. In this case your variable is assinged to a Integer and then you try to make it a type. Thats not allowed in Blitz3D Better is leave the local assingment out. As long as you do not declare it in the program its automaticly a local. Hope this wil work in your test program. |
| ||
| you're missing the point fernhout...we're not talking about blitz3d, but gamescript, the scripting language develped in blitz3d... more info: http://www.blitzbasic.com/Community/posts.php?topic=69531 btw: the reported bug got fixed. sincerly another one arised... |