Page 1 of 2
Scripting Help
Posted: September 24th, 2010, 9:35 pm
by tivial
i am trying to make a game that takes place on a desserted island where you will need to gather different resources to survive and i was wording how would i go about writing the scripts??
ie: Gathering Limbs,bark, and vines from trees.
Re: Scripting Help
Posted: September 24th, 2010, 9:43 pm
by PizzaLover101
Re: Scripting Help
Posted: September 24th, 2010, 9:46 pm
by chocolatepie33
In a bit, I have a whole thing on this... hold on...
Re: Scripting Help
Posted: September 24th, 2010, 9:47 pm
by daltonds1
Also.. You might want a inventory script.. Thats my TUT That he posted above:P
Heres the inv script
Add this at the top of your.cfg for your map if your map was called map (like saved name was map) Your config will be map.cfg
Code: Select all
newgui Inventory [
guibutton "Back" "cleargui 1"
guibar
guitext ( format "You have %1 Coins." $money )
guitext ( format "You have %1 treasures" $treasure )
guitext ( format "You have %1 Barrels" $barrel )
]
newgui main [
guilist [
guilist [
guibutton "Inventory" "showgui Inventory"
]
]
guibar
@main
]
Now if you want to add more
You will add this with your quest
apples = 0
then of course
Code: Select all
level_trigger_2 = [
apples = (+ $apples 1)
echo "You picked up a Apple!"
]
That will also be what you add to make it pickupable
Re: Scripting Help
Posted: September 24th, 2010, 9:51 pm
by chocolatepie33
Never mind, Dalton put it up... But actually, maybe I will put it up... Sorry, I made this before everyone else posted...
The way to do this would be with a script, you can make one by saving your map, re-loading it, and hitting F6 when you're in edit mode. Or you could externally make a .cfg with the mapname. Either way works.
You would start by adding a level trigger in-game, this would be an invisible mapmodel, you can add one by selecting a spot, hitting ` (above TAB) and typing: "newent mapmodel -1". Once this is done, you would select it and hit F3 and change the trigger type to 12 (a trigger that occurs once) and the level trigger to a #. Then your .cfg code would be like this:
Code: Select all
on_start = [
firewood-pieces = 0
vines = 0
rope = 0
]
level_trigger_1 = [firewood-pieces = ( + $firewood-pieces 1 ) ]
level_trigger_2 = [vines = ( + $vines 1 ) ]
level_trigger_3 = [ if ( > $vines 3 ) [ showgui npc1-1 ] ]
newgui npc1-1 [
guitext "you have enough vines for a rope."
guibar
guibutton "Make a rope?" [ vines = ( - $vines 4 ) rope = ( + $rope 1 ) ]
guibutton "Nah, just wait." [cleargui]
] "Yourself"
newgui inventory [
guitext ( format "You have %1 vines." $vines )
guitext ( format "You have %1 firewood-pieces." $firewood-pieces )
guitext ( format "You have %1 length(s) of rope." $rope )
]
newgui main [
guilist [
guilist [
guibutton "inventory" [showgui inventory]
]
]
guibar
@main
]
level trigger 1 adds a piece of firewood, 2 same for vines, 3 checks to see if you have 4 vines and asks if you want to make a rope. choosing yes removes 4 vines, but adds a rope. the inventory section creates an inventory showing how many items you have. You could use another if... statement to say "if you have at least 1 vine, then show it. otherwise, no text" within the inventory. The next part adds on the inventory to the main menu.
If I'm wrong, please correct me.
EDIT: Mine has an if statement script. So ha!
Re: Scripting Help
Posted: September 24th, 2010, 11:08 pm
by tivial
ok so now all i have to do is create an action button and plug it into the script??
Re: Scripting Help
Posted: September 24th, 2010, 11:12 pm
by chocolatepie33
ehh... Whaddya mean by an action button?
Re: Scripting Help
Posted: September 24th, 2010, 11:14 pm
by daltonds1
What you mean action button?
Just add this in your config file
Code: Select all
on_start = [
apples = 0
money = 0
barrel = 0
]
newgui Inventory [
guibutton "Back" "cleargui 1"
guibar
guitext ( format "You have %1 Coins." $money )
guitext ( format "You have %1 treasures" $treasure )
guitext ( format "You have %1 Barrels" $barrel )
]
newgui main [
guilist [
guilist [
guibutton "Inventory" "showgui Inventory"
]
]
guibar
@main
]
if you want to add something else to the inv
add this
itemname = 0 add that under barrel
then add this
guitext ( format "You have %1 Barrels" $itemname )
changing item name to what you put DONT remove the $
Re: Scripting Help
Posted: September 25th, 2010, 6:59 am
by PizzaLover101
You have three files per map. You have the .ogz, the art.cfg and the .cfg, The rest of the .bak files don't matter. Go into your mapname.cfg files and paste it in. Then make a mapmodel, trigger type 12 so you can pick it up, and then a trigger number so it will recognize when you pick it up and It'll go into your inventory
Re: Scripting Help
Posted: September 25th, 2010, 8:01 am
by tivial
Thanks all this has been realy informational. but i understand how to make things pickupable i want to be able to get the bark streight from the tree.